From 5bce52d6beea1a7dfd78768ebc6b77493f8647b8 Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Fri, 12 May 2017 19:00:55 +0200 Subject: [PATCH] try use_string_buffers lint (#10034) --- .analysis_options | 2 +- .analysis_options_repo | 2 +- packages/flutter/lib/src/rendering/layer.dart | 10 ++++++---- packages/flutter/lib/src/rendering/object.dart | 10 ++++++---- .../flutter/lib/src/rendering/semantics.dart | 11 +++++++---- .../flutter/lib/src/rendering/viewport.dart | 10 ++++++---- packages/flutter/lib/src/widgets/framework.dart | 11 +++++++---- packages/flutter/lib/src/widgets/overlay.dart | 17 +++++++++++------ 8 files changed, 45 insertions(+), 28 deletions(-) diff --git a/.analysis_options b/.analysis_options index 32d218bd6a..41998b7f6b 100644 --- a/.analysis_options +++ b/.analysis_options @@ -136,7 +136,7 @@ linter: - unnecessary_this # - use_rethrow_when_possible # not yet tested # - use_setters_to_change_properties # not yet tested - # - use_string_buffers # not yet tested + # - use_string_buffers # https://github.com/dart-lang/linter/pull/664 # - use_to_and_as_if_applicable # not yet tested # === pub rules === diff --git a/.analysis_options_repo b/.analysis_options_repo index 1f8624d61c..1971be978d 100644 --- a/.analysis_options_repo +++ b/.analysis_options_repo @@ -134,7 +134,7 @@ linter: - unnecessary_this # - use_rethrow_when_possible # not yet tested # - use_setters_to_change_properties # not yet tested - # - use_string_buffers # not yet tested + # - use_string_buffers # https://github.com/dart-lang/linter/pull/664 # - use_to_and_as_if_applicable # not yet tested # === pub rules === diff --git a/packages/flutter/lib/src/rendering/layer.dart b/packages/flutter/lib/src/rendering/layer.dart index a457af0bcb..0305d68ff4 100644 --- a/packages/flutter/lib/src/rendering/layer.dart +++ b/packages/flutter/lib/src/rendering/layer.dart @@ -349,19 +349,21 @@ class ContainerLayer extends Layer { String debugDescribeChildren(String prefix) { if (firstChild == null) return ''; - String result = '$prefix \u2502\n'; + final StringBuffer result = new StringBuffer() + ..write(prefix) + ..write(' \u2502\n'); Layer child = firstChild; int count = 1; while (child != lastChild) { - result += '${child.toStringDeep("$prefix \u251C\u2500child $count: ", "$prefix \u2502")}'; + result.write(child.toStringDeep("$prefix \u251C\u2500child $count: ", "$prefix \u2502")); count += 1; child = child.nextSibling; } if (child != null) { assert(child == lastChild); - result += '${child.toStringDeep("$prefix \u2514\u2500child $count: ", "$prefix ")}'; + result.write(child.toStringDeep("$prefix \u2514\u2500child $count: ", "$prefix ")); } - return result; + return result.toString(); } } diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index e7960f8de4..e27ad266cf 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -3059,20 +3059,22 @@ abstract class ContainerRenderObjectMixin children = []; visitChildren(children.add); if (children.isNotEmpty) { final Element last = children.removeLast(); for (Element child in children) - result += '${child.toStringDeep("$prefixOtherLines\u251C", "$prefixOtherLines\u2502")}'; - result += '${last.toStringDeep("$prefixOtherLines\u2514", "$prefixOtherLines ")}'; + result.write(child.toStringDeep("$prefixOtherLines\u251C", "$prefixOtherLines\u2502")); + result.write(last.toStringDeep("$prefixOtherLines\u2514", "$prefixOtherLines ")); } - return result; + return result.toString(); } /// Returns true if the element has been marked as needing rebuilding. diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index aa47c2b283..9f024dffcb 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -560,26 +560,31 @@ class _RenderTheatre extends RenderBox @override String debugDescribeChildren(String prefix) { - String result = ''; + final StringBuffer result = new StringBuffer(); if (child != null) - result += '$prefix \u2502\n${child.toStringDeep('$prefix \u251C\u2500onstage: ', '$prefix \u254E')}'; + result + ..write(prefix) + ..write(' \u2502\n') + ..write(child.toStringDeep('$prefix \u251C\u2500onstage: ', '$prefix \u254E')); if (firstChild != null) { RenderBox child = firstChild; int count = 1; while (child != lastChild) { - result += '${child.toStringDeep("$prefix \u254E\u254Coffstage $count: ", "$prefix \u254E")}'; + result.write(child.toStringDeep("$prefix \u254E\u254Coffstage $count: ", "$prefix \u254E")); count += 1; final StackParentData childParentData = child.parentData; child = childParentData.nextSibling; } if (child != null) { assert(child == lastChild); - result += '${child.toStringDeep("$prefix \u2514\u254Coffstage $count: ", "$prefix ")}'; + result.write(child.toStringDeep("$prefix \u2514\u254Coffstage $count: ", "$prefix ")); } } else { - result += '$prefix \u2514\u254Cno offstage children'; + result + ..write(prefix) + ..write(' \u2514\u254Cno offstage children'); } - return result; + return result.toString(); } @override