From 93a98327a89abb02fee80568f18c5656c4528053 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Thu, 3 Aug 2017 09:49:44 -0700 Subject: [PATCH] Add Diagnosticable base class and add documentation. (#11458) Add Diagnosticable base class and documentation --- .../lib/demo/animation/home.dart | 2 +- packages/flutter/lib/foundation.dart | 2 +- .../flutter/lib/src/cupertino/button.dart | 2 +- packages/flutter/lib/src/cupertino/page.dart | 16 +- .../flutter/lib/src/cupertino/slider.dart | 2 +- .../flutter/lib/src/cupertino/switch.dart | 4 +- .../lib/src/foundation/change_notifier.dart | 2 +- ...iagnostics_mixin.dart => diagnostics.dart} | 582 ++++++++++-------- .../flutter/lib/src/gestures/long_press.dart | 2 +- .../flutter/lib/src/gestures/monodrag.dart | 6 +- .../flutter/lib/src/gestures/multidrag.dart | 8 +- .../flutter/lib/src/gestures/multitap.dart | 4 +- .../flutter/lib/src/gestures/recognizer.dart | 19 +- packages/flutter/lib/src/gestures/scale.dart | 2 +- packages/flutter/lib/src/gestures/tap.dart | 2 +- packages/flutter/lib/src/material/button.dart | 2 +- .../flutter/lib/src/material/icon_button.dart | 2 +- .../flutter/lib/src/material/ink_well.dart | 2 +- .../lib/src/material/input_decorator.dart | 4 +- .../flutter/lib/src/material/material.dart | 2 +- .../lib/src/material/mergeable_material.dart | 8 +- .../lib/src/material/progress_indicator.dart | 2 +- packages/flutter/lib/src/material/slider.dart | 2 +- packages/flutter/lib/src/material/switch.dart | 2 +- packages/flutter/lib/src/material/tabs.dart | 2 +- .../flutter/lib/src/material/text_field.dart | 2 +- packages/flutter/lib/src/material/theme.dart | 4 +- .../flutter/lib/src/material/toggleable.dart | 2 +- .../flutter/lib/src/material/tooltip.dart | 2 +- .../flutter/lib/src/painting/box_painter.dart | 30 +- .../flutter/lib/src/painting/decoration.dart | 10 +- .../lib/src/painting/flutter_logo.dart | 19 +- .../flutter/lib/src/painting/text_span.dart | 69 +-- .../flutter/lib/src/painting/text_style.dart | 26 +- packages/flutter/lib/src/rendering/block.dart | 2 +- packages/flutter/lib/src/rendering/box.dart | 2 +- packages/flutter/lib/src/rendering/debug.dart | 15 +- .../flutter/lib/src/rendering/editable.dart | 2 +- packages/flutter/lib/src/rendering/flex.dart | 13 +- packages/flutter/lib/src/rendering/image.dart | 2 +- packages/flutter/lib/src/rendering/layer.dart | 28 +- .../flutter/lib/src/rendering/object.dart | 11 +- .../flutter/lib/src/rendering/proxy_box.dart | 44 +- .../lib/src/rendering/shifted_box.dart | 12 +- .../flutter/lib/src/rendering/sliver.dart | 63 +- .../rendering/sliver_multi_box_adaptor.dart | 2 +- .../rendering/sliver_persistent_header.dart | 4 +- packages/flutter/lib/src/rendering/stack.dart | 4 +- packages/flutter/lib/src/rendering/table.dart | 2 +- packages/flutter/lib/src/rendering/view.dart | 2 +- .../flutter/lib/src/rendering/viewport.dart | 4 +- packages/flutter/lib/src/rendering/wrap.dart | 2 +- .../lib/src/services/image_stream.dart | 64 +- .../lib/src/widgets/animated_cross_fade.dart | 4 +- .../lib/src/widgets/automatic_keep_alive.dart | 2 +- packages/flutter/lib/src/widgets/banner.dart | 4 +- packages/flutter/lib/src/widgets/basic.dart | 54 +- .../flutter/lib/src/widgets/container.dart | 4 +- .../lib/src/widgets/editable_text.dart | 2 +- .../lib/src/widgets/fade_in_image.dart | 2 +- .../lib/src/widgets/focus_manager.dart | 4 +- .../flutter/lib/src/widgets/framework.dart | 98 +-- .../lib/src/widgets/gesture_detector.dart | 4 +- packages/flutter/lib/src/widgets/icon.dart | 2 +- .../flutter/lib/src/widgets/icon_theme.dart | 2 +- packages/flutter/lib/src/widgets/image.dart | 4 +- .../flutter/lib/src/widgets/image_icon.dart | 2 +- .../lib/src/widgets/implicit_animations.dart | 16 +- .../flutter/lib/src/widgets/locale_query.dart | 2 +- .../flutter/lib/src/widgets/media_query.dart | 2 +- packages/flutter/lib/src/widgets/overlay.dart | 2 +- .../lib/src/widgets/overscroll_indicator.dart | 2 +- .../flutter/lib/src/widgets/page_view.dart | 2 +- .../widgets/primary_scroll_controller.dart | 2 +- .../src/widgets/raw_keyboard_listener.dart | 2 +- packages/flutter/lib/src/widgets/routes.dart | 2 +- .../lib/src/widgets/scroll_configuration.dart | 2 +- .../flutter/lib/src/widgets/scroll_view.dart | 6 +- .../flutter/lib/src/widgets/scrollable.dart | 4 +- packages/flutter/lib/src/widgets/sliver.dart | 4 +- .../src/widgets/sliver_persistent_header.dart | 4 +- packages/flutter/lib/src/widgets/table.dart | 2 +- packages/flutter/lib/src/widgets/text.dart | 4 +- .../lib/src/widgets/ticker_provider.dart | 6 +- packages/flutter/lib/src/widgets/title.dart | 2 +- .../flutter/lib/src/widgets/transitions.dart | 2 +- .../flutter/lib/src/widgets/viewport.dart | 4 +- ..._mixin_test.dart => diagnostics_test.dart} | 79 +-- .../test/gestures/recognizer_test.dart | 2 +- .../flutter/test/painting/text_span_test.dart | 2 +- packages/flutter/test/rendering/box_test.dart | 4 +- .../flutter/test/rendering/debug_test.dart | 15 +- .../test/widgets/animated_container_test.dart | 2 +- .../flutter/test/widgets/container_test.dart | 6 +- .../flutter/test/widgets/framework_test.dart | 35 +- .../widgets/global_keys_duplicated_test.dart | 6 +- packages/flutter/test/widgets/image_test.dart | 6 +- .../test/widgets/overflow_box_test.dart | 6 +- packages/flutter/test/widgets/table_test.dart | 2 +- 99 files changed, 753 insertions(+), 797 deletions(-) rename packages/flutter/lib/src/foundation/{tree_diagnostics_mixin.dart => diagnostics.dart} (83%) rename packages/flutter/test/foundation/{tree_diagnostics_mixin_test.dart => diagnostics_test.dart} (96%) diff --git a/examples/flutter_gallery/lib/demo/animation/home.dart b/examples/flutter_gallery/lib/demo/animation/home.dart index b0d4a986b3..0b1d1a2791 100644 --- a/examples/flutter_gallery/lib/demo/animation/home.dart +++ b/examples/flutter_gallery/lib/demo/animation/home.dart @@ -102,7 +102,7 @@ class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('maxHeight', maxHeight)); description.add(new DoubleProperty('scrollFactor', scrollFactor)); diff --git a/packages/flutter/lib/foundation.dart b/packages/flutter/lib/foundation.dart index 007208a8bb..5d06b779eb 100644 --- a/packages/flutter/lib/foundation.dart +++ b/packages/flutter/lib/foundation.dart @@ -38,6 +38,7 @@ export 'src/foundation/binding.dart'; export 'src/foundation/change_notifier.dart'; export 'src/foundation/collections.dart'; export 'src/foundation/debug.dart'; +export 'src/foundation/diagnostics.dart'; export 'src/foundation/licenses.dart'; export 'src/foundation/observer_list.dart'; export 'src/foundation/platform.dart'; @@ -45,4 +46,3 @@ export 'src/foundation/print.dart'; export 'src/foundation/profile.dart'; export 'src/foundation/serialization.dart'; export 'src/foundation/synchronous_future.dart'; -export 'src/foundation/tree_diagnostics_mixin.dart'; diff --git a/packages/flutter/lib/src/cupertino/button.dart b/packages/flutter/lib/src/cupertino/button.dart index 358b50e3ee..b9f0e9f49b 100644 --- a/packages/flutter/lib/src/cupertino/button.dart +++ b/packages/flutter/lib/src/cupertino/button.dart @@ -101,7 +101,7 @@ class CupertinoButton extends StatefulWidget { _CupertinoButtonState createState() => new _CupertinoButtonState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('enabled', value: enabled, ifFalse: 'disabled')); } diff --git a/packages/flutter/lib/src/cupertino/page.dart b/packages/flutter/lib/src/cupertino/page.dart index e066c134f0..ee44919636 100644 --- a/packages/flutter/lib/src/cupertino/page.dart +++ b/packages/flutter/lib/src/cupertino/page.dart @@ -424,19 +424,9 @@ class _CupertinoEdgeShadowDecoration extends Decoration { } @override - DiagnosticsNode toDiagnosticsNode({ - String name, - DiagnosticsTreeStyle style: DiagnosticsTreeStyle.singleLine, - }) { - return new DiagnosticsNode.lazy( - name: name, - value: this, - style: style, - description: '$runtimeType', - fillProperties: (List properties) { - properties.add(new DiagnosticsProperty('edgeGradient', edgeGradient)); - }, - ); + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(new DiagnosticsProperty('edgeGradient', edgeGradient)); } } diff --git a/packages/flutter/lib/src/cupertino/slider.dart b/packages/flutter/lib/src/cupertino/slider.dart index 147f7d5daa..42cc96ab7a 100644 --- a/packages/flutter/lib/src/cupertino/slider.dart +++ b/packages/flutter/lib/src/cupertino/slider.dart @@ -111,7 +111,7 @@ class CupertinoSlider extends StatefulWidget { _CupertinoSliderState createState() => new _CupertinoSliderState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('value', value)); description.add(new DoubleProperty('min', min)); diff --git a/packages/flutter/lib/src/cupertino/switch.dart b/packages/flutter/lib/src/cupertino/switch.dart index c638179c4e..9579ca735c 100644 --- a/packages/flutter/lib/src/cupertino/switch.dart +++ b/packages/flutter/lib/src/cupertino/switch.dart @@ -88,7 +88,7 @@ class CupertinoSwitch extends StatefulWidget { _CupertinoSwitchState createState() => new _CupertinoSwitchState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('value', value: value, ifTrue: 'on', ifFalse: 'off', showName: true)); description.add(new ObjectFlagProperty>('onChanged', onChanged, ifNull: 'disabled')); @@ -419,7 +419,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox implements SemanticsAc } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('value', value: value, ifTrue: 'checked', ifFalse: 'unchecked', showName: true)); description.add(new FlagProperty('isInteractive', value: isInteractive, ifTrue: 'enabled', ifFalse: 'disabled', showName: true, defaultValue: true)); diff --git a/packages/flutter/lib/src/foundation/change_notifier.dart b/packages/flutter/lib/src/foundation/change_notifier.dart index 46407cf360..7e207ed2fd 100644 --- a/packages/flutter/lib/src/foundation/change_notifier.dart +++ b/packages/flutter/lib/src/foundation/change_notifier.dart @@ -6,8 +6,8 @@ import 'package:meta/meta.dart'; import 'assertions.dart'; import 'basic_types.dart'; +import 'diagnostics.dart'; import 'observer_list.dart'; -import 'tree_diagnostics_mixin.dart'; /// An object that maintains a list of listeners. abstract class Listenable { diff --git a/packages/flutter/lib/src/foundation/tree_diagnostics_mixin.dart b/packages/flutter/lib/src/foundation/diagnostics.dart similarity index 83% rename from packages/flutter/lib/src/foundation/tree_diagnostics_mixin.dart rename to packages/flutter/lib/src/foundation/diagnostics.dart index b2d3062b1b..026fe0d6c4 100644 --- a/packages/flutter/lib/src/foundation/tree_diagnostics_mixin.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -63,7 +63,7 @@ enum DiagnosticsTreeStyle { /// See also: /// /// * [sparseTextConfiguration], which is a typical style. -/// * [leafTextConfiguration], which is an example of a complex tree style. +/// * [transitionTextConfiguration], which is an example of a complex tree style. /// * [DiagnosticsNode.toStringDeep], for code using [TextTreeConfiguration] /// to render text art for arbitrary trees of [DiagnosticsNode] objects. class TextTreeConfiguration { @@ -79,6 +79,7 @@ class TextTreeConfiguration { @required this.propertyPrefixIfChildren, @required this.propertyPrefixNoChildren, this.lineBreak: '\n', + this.lineBreakProperties: true, this.afterName: ':', this.afterDescriptionIfBody: '', this.beforeProperties: '', @@ -98,6 +99,7 @@ class TextTreeConfiguration { assert(propertyPrefixIfChildren != null), assert(propertyPrefixNoChildren != null), assert(lineBreak != null), + assert(lineBreakProperties != null), assert(afterName != null), assert(afterDescriptionIfBody != null), assert(beforeProperties != null), @@ -158,10 +160,14 @@ class TextTreeConfiguration { /// [singleLineTextConfiguration]. final String lineBreak; + /// Whether to place line breaks between properties or to leave all + /// properties on one line. + final bool lineBreakProperties; + /// Text added immediately after the name of the node. /// - /// See [leafTextConfiguration] for an example of using a value other than ':' - /// to achieve a custom line art style. + /// See [transitionTextConfiguration] for an example of using a value other + /// than ':' to achieve a custom line art style. final String afterName; /// Text to add immediately after the description line of a node with @@ -208,15 +214,12 @@ class TextTreeConfiguration { /// Footer to add as its own line at the end of a non-root node. /// - /// See [leafTextConfiguration] for an example of using footer to draw a box + /// See [transitionTextConfiguration] for an example of using footer to draw a box /// around the node. [footer] is indented the same amount as [prefixOtherLines]. final String footer; /// Add a blank line between properties and children if both are present. final bool isBlankLineBetweenPropertiesAndChildren; - - /// Whether all text should be added to a single line. - bool get isSingleLine => lineBreak.isEmpty; } /// Default text tree configuration. @@ -320,29 +323,19 @@ final TextTreeConfiguration dashedTextConfiguration = new TextTreeConfiguration( /// /// Example: /// ``` -/// : -/// │ -/// │ -/// │ ... -/// │ -/// │ -/// ├: -/// │ -/// │ -/// │ ... -/// │ -/// │ -/// └: ' -/// -/// -/// ... -/// +/// : (; ) +/// ├: (, , ) +/// └: (, , ) /// ``` /// /// See also: /// /// * [DiagnosticsTreeStyle.dense] final TextTreeConfiguration denseTextConfiguration = new TextTreeConfiguration( + propertySeparator: ', ', + beforeProperties: '(', + afterProperties: ')', + lineBreakProperties: false, prefixLineOne: '├', prefixOtherLines: '', prefixLastChildLineOne: '└', @@ -351,6 +344,7 @@ final TextTreeConfiguration denseTextConfiguration = new TextTreeConfiguration( propertyPrefixNoChildren: ' ', prefixOtherLinesRootNode: '', addBlankLineIfNoChildren: false, + isBlankLineBetweenPropertiesAndChildren: false, ); /// Configuration that draws a box around a leaf node. @@ -376,7 +370,7 @@ final TextTreeConfiguration denseTextConfiguration = new TextTreeConfiguration( /// /// See also: /// /// * [DiagnosticsTreeStyle.transition] -final TextTreeConfiguration leafTextConfiguration = new TextTreeConfiguration( +final TextTreeConfiguration transitionTextConfiguration = new TextTreeConfiguration( prefixLineOne: '╞═╦══ ', prefixLastChildLineOne: '╘═╦══ ', prefixOtherLines: ' ║ ', @@ -406,7 +400,7 @@ final TextTreeConfiguration leafTextConfiguration = new TextTreeConfiguration( /// two spaces. /// /// Use this style for displaying properties with structured values or for -/// displaying children within a [leafTextConfiguration] as using a style that +/// displaying children within a [transitionTextConfiguration] as using a style that /// draws line art would be visually distracting for those cases. /// /// Example: @@ -455,6 +449,7 @@ final TextTreeConfiguration singleLineTextConfiguration = new TextTreeConfigurat prefixOtherLines: '', prefixLastChildLineOne: '', lineBreak: '', + lineBreakProperties: false, addBlankLineIfNoChildren: false, showChildren: false, propertyPrefixIfChildren: '', @@ -584,12 +579,10 @@ abstract class DiagnosticsNode { /// The [style], [showName] and [showSeparator] arguments must not be null. DiagnosticsNode({ @required this.name, - this.style: DiagnosticsTreeStyle.sparse, + this.style, this.showName: true, this.showSeparator: true, - this.emptyBodyDescription, - }) : assert(style != null), - assert(showName != null), + }) : assert(showName != null), assert(showSeparator != null) { // A name ending with ':' indicates that the user forgot that the ':' will // be automatically added for them when generating descriptions of the @@ -597,31 +590,6 @@ abstract class DiagnosticsNode { assert(name == null || !name.endsWith(':'), 'Names of diagnostic nodes must not end with colons.'); } - /// Constructor that creates a [DiagnosticsNode] where properties and children - /// are computed lazily. - /// - /// The [style] argument must not be null. - factory DiagnosticsNode.lazy({ - String name, - Object value, - String description, - FillPropertiesCallback fillProperties, - GetChildrenCallback getChildren, - String emptyBodyDescription, - DiagnosticsTreeStyle style: DiagnosticsTreeStyle.sparse, - }) { - assert(style != null); - return new _LazyMembersDiagnosticsNode( - name: name, - value: value, - description: description, - fillProperties: fillProperties, - getChildren: getChildren, - style: style, - emptyBodyDescription: emptyBodyDescription, - ); - } - /// Diagnostics containing just a string `message` and not a concrete name or /// value. /// @@ -651,9 +619,13 @@ abstract class DiagnosticsNode { /// The name will be omitted if the [showName] property is false. final String name; - /// Description with a short summary of the node itself not including children - /// or properties. - String get description; + /// Returns a description with a short summary of the node itself not + /// including children or properties. + /// + /// `parentConfiguration` specifies how the parent is rendered as text art. + /// For example, if the parent does not line break between properties, the + /// description of a property should also be a single line if possible. + String toDescription({ TextTreeConfiguration parentConfiguration }); /// Whether to show a separator between [name] and [description]. /// @@ -673,7 +645,7 @@ abstract class DiagnosticsNode { final bool showName; /// Description to show if the node has no displayed properties or children. - final String emptyBodyDescription; + String get emptyBodyDescription => null; /// The actual object this is diagnostics data for. Object get value; @@ -696,11 +668,19 @@ abstract class DiagnosticsNode { String get _separator => showSeparator ? ':' : ''; + /// Returns a string representation of this diagnostic that is compatible with + /// the style of the parent if the node is not the root. + /// + /// `parentConfiguration` specifies how the parent is rendered as text art. + /// For example, if the parent places all properties on one line, the + /// [toString] for each property should avoid line breaks if possible. @override - String toString() { + String toString({ TextTreeConfiguration parentConfiguration }) { assert(style != null); if (style == DiagnosticsTreeStyle.singleLine) - return toStringDeep(); + return toStringDeep('', '', parentConfiguration); + + final String description = toDescription(parentConfiguration: parentConfiguration); if (name == null || name.isEmpty || !showName) return description; @@ -709,6 +689,9 @@ abstract class DiagnosticsNode { : '$name$_separator $description'; } + /// Returns a configuration specifying how this object should be rendered + /// as text art. + @protected TextTreeConfiguration get textTreeConfiguration { assert(style != null); switch (style) { @@ -721,7 +704,7 @@ abstract class DiagnosticsNode { case DiagnosticsTreeStyle.whitespace: return whitespaceTextConfiguration; case DiagnosticsTreeStyle.transition: - return leafTextConfiguration; + return transitionTextConfiguration; case DiagnosticsTreeStyle.singleLine: return singleLineTextConfiguration; } @@ -752,7 +735,7 @@ abstract class DiagnosticsNode { /// * [toString], for a brief description of the [value] but not its children. /// * [toStringShallow], for a detailed description of the [value] but not its /// children. - String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) { + String toStringDeep([String prefixLineOne = '', String prefixOtherLines, TextTreeConfiguration parentConfiguration]) { prefixOtherLines ??= prefixLineOne; final List children = getChildren(); @@ -763,6 +746,7 @@ abstract class DiagnosticsNode { final _PrefixedStringBuilder builder = new _PrefixedStringBuilder( prefixLineOne, prefixOtherLines); + final String description = toDescription(parentConfiguration: parentConfiguration); if (description == null || description.isEmpty) { if (showName && name != null) builder.write(name); @@ -785,9 +769,11 @@ abstract class DiagnosticsNode { if (properties.isNotEmpty || children.isNotEmpty || emptyBodyDescription != null) builder.write(config.afterDescriptionIfBody); + if (config.lineBreakProperties) + builder.write(config.lineBreak); + if (properties.isNotEmpty) builder.write(config.beforeProperties); - builder.write(config.lineBreak); builder.prefixOtherLines += config.bodyIndent; @@ -795,7 +781,9 @@ abstract class DiagnosticsNode { properties.isEmpty && children.isEmpty && prefixLineOne.isNotEmpty) { - builder..write(emptyBodyDescription)..write(config.lineBreak); + builder.write(emptyBodyDescription); + if (config.lineBreakProperties) + builder.write(config.lineBreak); } for (int i = 0; i < properties.length; ++i) { @@ -809,12 +797,13 @@ abstract class DiagnosticsNode { builder.writeRaw(property.toStringDeep( '${builder.prefixOtherLines}${propertyStyle.prefixLineOne}', '${builder.prefixOtherLines}${propertyStyle.linkCharacter}${propertyStyle.prefixOtherLines}', + config, )); continue; } assert(property.style == DiagnosticsTreeStyle.singleLine); - final String message = property == null ? '' : property.toString(); - if (config.isSingleLine || message.length < kWrapWidth) { + final String message = property.toString(parentConfiguration: config); + if (!config.lineBreakProperties || message.length < kWrapWidth) { builder.write(message); } else { // debugWordWrap doesn't handle line breaks within the text being @@ -827,11 +816,15 @@ abstract class DiagnosticsNode { builder.write(debugWordWrap(line, kWrapWidth, wrapIndent: ' ').join('\n')); } } - builder.write(config.lineBreak); + if (config.lineBreakProperties) + builder.write(config.lineBreak); } if (properties.isNotEmpty) builder.write(config.afterProperties); + if (!config.lineBreakProperties) + builder.write(config.lineBreak); + final String prefixChildren = '$prefixOtherLines${config.bodyIndent}'; if (children.isEmpty && @@ -862,10 +855,10 @@ abstract class DiagnosticsNode { builder.writeRawLine(child.toStringDeep( lastChildPrefixLineOne, '$prefixChildren${childConfig.childLinkSpace}${childConfig.prefixOtherLines}', + config, )); if (childConfig.footer.isNotEmpty) builder.writeRaw('$prefixChildren${childConfig.childLinkSpace}${childConfig.footer}'); - } else { final TextTreeConfiguration nextChildStyle = _childTextConfiguration(children[i + 1], config); @@ -961,8 +954,17 @@ class StringProperty extends DiagnosticsProperty { final bool quoted; @override - String valueToString() { - final String text = _description ?? value; + String valueToString({ TextTreeConfiguration parentConfiguration }) { + String text = _description ?? value; + if (parentConfiguration != null && + !parentConfiguration.lineBreakProperties && + text != null) { + // Escape linebreaks in multiline strings to avoid confusing output when + // the parent of this node is trying to display all properties on the same + // line. + text = text.replaceAll('\n', '\\n'); + } + if (quoted && text != null) { // An empty value would not appear empty after being surrounded with // quotes so we have to handle this case separately. @@ -1023,7 +1025,7 @@ abstract class _NumProperty extends DiagnosticsProperty { String numberToString(); @override - String valueToString() { + String valueToString({ TextTreeConfiguration parentConfiguration }) { if (value == null) return value.toString(); @@ -1138,7 +1140,7 @@ class PercentProperty extends DoubleProperty { ); @override - String valueToString() { + String valueToString({ TextTreeConfiguration parentConfiguration }) { if (value == null) return value.toString(); return unit != null ? '${numberToString()} $unit' : numberToString(); @@ -1223,7 +1225,7 @@ class FlagProperty extends DiagnosticsProperty { final String ifFalse; @override - String valueToString() { + String valueToString({ TextTreeConfiguration parentConfiguration }) { if (value == true) return ifTrue ?? ''; if (value == false) @@ -1277,11 +1279,17 @@ class IterableProperty extends DiagnosticsProperty> { ); @override - String valueToString() { + String valueToString({ TextTreeConfiguration parentConfiguration }) { if (value == null) return value.toString(); - return style == DiagnosticsTreeStyle.singleLine ? value.join(', ') - : value.join('\n'); + + if (parentConfiguration != null && !parentConfiguration.lineBreakProperties) { + // Always display the value as a single line and enclose the iterable + // value in brackets to avoid ambiguity. + return '[${value.join(', ')}]'; + } + + return value.join(style == DiagnosticsTreeStyle.singleLine ? ', ' : '\n'); } } @@ -1309,7 +1317,7 @@ class EnumProperty extends DiagnosticsProperty { ); @override - String valueToString() { + String valueToString({ TextTreeConfiguration parentConfiguration }) { if (value == null) return value.toString(); return camelCaseToHyphenatedName(describeEnum(value)); @@ -1378,7 +1386,7 @@ class ObjectFlagProperty extends DiagnosticsProperty { final String ifPresent; @override - String valueToString() { + String valueToString({ TextTreeConfiguration parentConfiguration }) { if (value != null) return ifPresent ?? ''; @@ -1484,17 +1492,27 @@ class DiagnosticsProperty extends DiagnosticsNode { /// Returns a string representation of the property value. /// - /// Subclasses should override this method instead of [description] to + /// Subclasses should override this method instead of [toDescription] to /// customize how property values are converted to strings. /// /// Overriding this method ensures that behavior controlling how property /// values are decorated to generate a nice description are consistent across /// all implementations. Debugging tools may also choose to use /// [valueToString] directly instead of [description]. - String valueToString() => value.toString(); + /// + /// `parentConfiguration` specifies how the parent is rendered as text art. + /// For example, if the parent places all properties on one line, the value + /// of the property should be displayed without line breaks if possible. + String valueToString({ TextTreeConfiguration parentConfiguration }) { + final T v = value; + // DiagnosticableTree values are shown using the shorter toStringShort() + // instead of the longer toString() because the toString() for a + // DiagnosticableTree value is likely too large to be useful. + return v is DiagnosticableTree ? v.toStringShort() : v.toString(); + } @override - String get description { + String toDescription({ TextTreeConfiguration parentConfiguration }) { if (_description != null) return _addTooltip(_description); @@ -1504,7 +1522,7 @@ class DiagnosticsProperty extends DiagnosticsNode { if (ifNull != null && value == null) return _addTooltip(ifNull); - String result = valueToString(); + String result = valueToString(parentConfiguration: parentConfiguration); if (result.isEmpty && ifEmpty != null) result = ifEmpty; return _addTooltip(result); @@ -1591,6 +1609,10 @@ class DiagnosticsProperty extends DiagnosticsNode { } } + /// If the [value] of the property equals [defaultValue] the property is + /// [hidden] as the [value] is uninteresting. + /// + /// [defaultValue] has type [T] or is [kNoDefaultValue]. final Object defaultValue; final bool _hidden; @@ -1621,103 +1643,72 @@ class DiagnosticsProperty extends DiagnosticsNode { List getChildren() => []; } -/// Add additional properties describing an object. -/// -/// See also: -/// -/// * [TreeDiagnosticsMixin.debugFillProperties], which lists best practices -/// for specifying properties. -typedef void FillPropertiesCallback(List properties); - -/// Returns a list of [DiagnosticsNode] objects describing an object's children. -/// -/// See also: -/// -/// * [TreeDiagnosticsMixin.debugDescribeChildren], which lists best practices -/// for describing children. -typedef List GetChildrenCallback(); - -class _LazyMembersDiagnosticsNode extends DiagnosticsNode { - _LazyMembersDiagnosticsNode({ - @required String name, - @required String description, +/// [DiagnosticsNode] for an instance of [Diagnosticable]. +class _DiagnosticableNode extends DiagnosticsNode { + _DiagnosticableNode({ + String name, @required this.value, - GetChildrenCallback getChildren, - FillPropertiesCallback fillProperties, + @required DiagnosticsTreeStyle style, String emptyBodyDescription, - DiagnosticsTreeStyle style: DiagnosticsTreeStyle.sparse, - }) : assert(style != null), - _description = description, - _getChildren = getChildren, - _fillProperties = fillProperties, - super( + }) : super( name: name, style: style, - emptyBodyDescription: emptyBodyDescription, ); @override - final Object value; + final T value; - final GetChildrenCallback _getChildren; - final FillPropertiesCallback _fillProperties; + DiagnosticPropertiesBuilder _cachedBuilder; - final String _description; - - @override - bool get hidden => false; - - @override - String get description => _description ?? value.toString(); - - @override - List getProperties() { - final List properties = []; - if (_fillProperties != null) - _fillProperties(properties); - return properties; + DiagnosticPropertiesBuilder get _builder { + if (_cachedBuilder == null) { + _cachedBuilder = new DiagnosticPropertiesBuilder(); + value?.debugFillProperties(_cachedBuilder); + } + return _cachedBuilder; } + @override DiagnosticsTreeStyle get style { + return super.style ?? _builder.defaultDiagnosticsTreeStyle; + } + + @override + String get emptyBodyDescription => _builder.emptyBodyDescription; + + @override + List getProperties() => _builder.properties; + @override List getChildren() { - return _getChildren != null ? _getChildren() : []; + return const[]; } + + @override + String toDescription({ TextTreeConfiguration parentConfiguration }) { + return value.toStringShort(); + } + + @override bool get hidden => false; } -/// [DiagnosticsNode] for an instance of [TreeDiagnosticsMixin]. -class _TreeDiagnosticsMixinNode extends DiagnosticsNode { - _TreeDiagnosticsMixinNode({ +/// [DiagnosticsNode] for an instance of [DiagnosticableTree]. +class _DiagnosticableTreeNode extends _DiagnosticableNode { + _DiagnosticableTreeNode({ String name, - this.value, + @required DiagnosticableTree value, @required DiagnosticsTreeStyle style, - }) : assert(style != null), - super( - name: name, - style: style, - ); - - @override - final TreeDiagnosticsMixin value; - - @override - List getProperties() { - final List description = []; - if (value != null) - value.debugFillProperties(description); - return description; - } + }) : super( + name: name, + value: value, + style: style, + ); @override List getChildren() { if (value != null) return value.debugDescribeChildren(); - return []; + return const []; } - - @override - String get description => value.toString(); - - @override bool get hidden => false; } /// Returns a 5 character long hexadecimal string generated from @@ -1787,7 +1778,29 @@ String camelCaseToHyphenatedName(String word) { return buffer.toString(); } -/// An interface providing string and [DiagnosticsNode] debug representations. +/// Builder to accumulate properties and configuration used to assemble a +/// [DiagnosticsNode] from a [Diagnosticable] object. +class DiagnosticPropertiesBuilder { + /// Add a property to the list of properties. + void add(DiagnosticsNode property) { + properties.add(property); + } + + /// List of properties accumulated so far. + final List properties = []; + + /// Default style to use for the [DiagnosticsNode] if no style is specified. + DiagnosticsTreeStyle defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.sparse; + + /// Description to show if the node has no displayed properties or children. + String emptyBodyDescription; +} + +// Examples can assume: +// class ExampleSuperclass extends Diagnosticable { String message; double stepWidth; double scale; double paintExtent; double hitTestExtent; double paintExtend; double maxWidth; bool primary; double progress; int maxLines; Duration duration; int depth; dynamic boxShadow; dynamic style; bool hasSize; Matrix4 transform; Map handles; Color color; bool obscureText; ImageRepeat repeat; Size size; Widget widget; bool isCurrent; bool keepAlive; TextAlign textAlign; } + +/// A base class for providing string and [DiagnosticsNode] debug +/// representations describing the properties of an object. /// /// The string debug representation is generated from the intermediate /// [DiagnosticsNode] representation. The [DiagnosticsNode] representation is @@ -1796,111 +1809,48 @@ String camelCaseToHyphenatedName(String word) { /// /// See also: /// -/// * [TreeDiagnosticsMixin], which provides convenience members for implementing -/// this interface in a consistent way. -/// * The documentation for [TreeDiagnosticsMixin.debugFillProperties], which -/// lists best practices for specifying the properties of a -/// [DiagnosticsNode]. The most common use case is to override -/// [TreeDiagnosticsMixin.debugFillProperties] to define custom properties -/// for a subclass of [TreeDiagnosticsMixin] using the existing +/// * [DiagnosticableTree], which extends this class to also describe the +/// children of a tree structured object. +/// * [Diagnosticable.debugFillProperties], which lists best practices +/// for specifying the properties of a [DiagnosticNode]. The most common use +/// case is to override [debugFillProperties] defining custom properties for +/// a subclass of [TreeDiagnosticsMixin] using the existing /// [DiagnosticsProperty] subclasses. -/// * The documentation for [TreeDiagnosticsMixin.debugDescribeChildren], which -/// lists best practices for describing the children of a [DiagnosticsNode]. -/// Typically the base class already describes the children of a node -/// properly or a node has no children. -/// * [DiagnosticsProperty], which describes leaf diagnostic nodes without -/// properties or children. There are many [DiagnosticsProperty] subclasses -/// to handle common use cases such as strings and doubles. -abstract class TreeDiagnostics { +/// * [DiagnosticableTree.debugDescribeChildren], which lists best practices +/// for describing the children of a [DiagnosticNode]. Typically the base +/// class already describes the children of a node properly or a node has +/// no children. +/// * [DiagnosticsProperty], which should be used to create leaf diagnostic +/// nodes without properties or children. There are many [DiagnosticProperty] +/// subclasses to handle common use cases. +abstract class Diagnosticable { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. - const TreeDiagnostics(); - - /// The [toStringDeep] method takes arguments, but those are intended for - /// internal use when recursing to the descendants, and so can be ignored. - /// - /// See also: - /// - /// * [toString], for a brief description of the object but not its children. - /// * [TreeDiagnosticsMixin.toStringShallow], for a detailed description of - /// the object but not its children. - String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) { - return toDiagnosticsNode().toStringDeep(prefixLineOne, prefixOtherLines); - } - - // `name` may be null, but `style` must not be. - // TODO(jacobr): document the semantics of the arguments, including what it means when name is null. - DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style: DiagnosticsTreeStyle.sparse }); -} - -// Examples can assume: -// class ExampleSuperclass { String message; double stepWidth; double scale; double paintExtent; double hitTestExtent; double paintExtend; double maxWidth; bool primary; double progress; int maxLines; Duration duration; int depth; dynamic boxShadow; dynamic style; bool hasSize; Matrix4 transform; Map handles; Color color; bool obscureText; ImageRepeat repeat; Size size; Widget widget; bool isCurrent; bool keepAlive; TextAlign textAlign; } - -/// A mixin that helps dump string and [DiagnosticsNode] representations of -/// trees. -/// -/// Use this class to implement [TreeDiagnostics] any time it is possible to use -/// mixins. -abstract class TreeDiagnosticsMixin implements TreeDiagnostics { - // This class is intended to be used as a mixin, and should not be - // extended directly. - factory TreeDiagnosticsMixin._() => null; + const Diagnosticable(); /// A brief description of this object, usually just the [runtimeType] and the /// [hashCode]. /// /// See also: /// - /// * [toStringShallow], for a detailed description of the object. - /// * [toStringDeep], for a description of the subtree rooted at this object. - @override - String toString() => describeIdentity(this); + /// * [toString], for a detailed description of the object. + String toStringShort() => describeIdentity(this); - /// Returns a one-line detailed description of the object. - /// - /// This description is often somewhat long. This includes the same - /// information given by [toStringDeep], but does not recurse to any children. - /// - /// The [toStringShallow] method can take an argument, which is the string to - /// place between each part obtained from [debugFillProperties]. Passing a - /// string such as `'\n '` will result in a multiline string that indents the - /// properties of the object below its name (as per [toString]). - /// - /// See also: - /// - /// * [toString], for a brief description of the object. - /// * [toStringDeep], for a description of the subtree rooted at this object. - String toStringShallow([String joiner = '; ']) { - final StringBuffer result = new StringBuffer(); - result.write(toString()); - result.write(joiner); - final List properties = []; - debugFillProperties(properties); - result.write( - properties.where((DiagnosticsNode n) => !n.hidden).join(joiner), - ); - return result.toString(); + @override String toString() { + return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(); } - /// Returns a string representation of this node and its descendants. + /// Returns a debug representation of the object that is used by debugging + /// tools and by [toStringDeep]. /// - /// The [toStringDeep] method takes arguments, but those are intended for - /// internal use when recursing to the descendants, and so can be ignored. + /// Leave [name] as `null` if there is not a meaningful description of the + /// relationship between the this node and its parent. /// - /// See also: - /// - /// * [toString], for a brief description of the object but not its children. - /// * [toStringShallow], for a detailed description of the object but not its - /// children. - @override - String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) { - return toDiagnosticsNode().toStringDeep(prefixLineOne, prefixOtherLines); - } - - @override - DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style: DiagnosticsTreeStyle.sparse }) { - assert(style != null); - return new _TreeDiagnosticsMixinNode( + /// Typically the [style] argument is only specified to indicate an atypical + /// relationship between the parent and the node. For example, pass + /// [DiagnosticsTreeStyle.offstage] to indicate that a node is offstage. + DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { + return new _DiagnosticableNode( name: name, value: this, style: style, @@ -1985,12 +1935,12 @@ abstract class TreeDiagnosticsMixin implements TreeDiagnostics { /// common [DiagnosticsProperty] parameters. /// /// ```dart - /// abstract class ExampleObject extends ExampleSuperclass with TreeDiagnosticsMixin { + /// class ExampleObject extends ExampleSuperclass { /// /// // ...various members and properties... /// /// @override - /// void debugFillProperties(List description) { + /// void debugFillProperties(DiagnosticPropertiesBuilder description) { /// // Always add properties from the base class first. /// super.debugFillProperties(description); /// @@ -2108,10 +2058,82 @@ abstract class TreeDiagnosticsMixin implements TreeDiagnostics { /// } /// ``` /// - /// Used by [toStringDeep], [toDiagnosticsNode] and [toStringShallow]. + /// Used by [toDiagnosticsNode] and [toString]. @protected @mustCallSuper - void debugFillProperties(List properties) { } + void debugFillProperties(DiagnosticPropertiesBuilder properties) { } +} + +/// A base class for providing string and [DiagnosticsNode] debug +/// representations describing the properties and children of an object. +/// +/// The string debug representation is generated from the intermediate +/// [DiagnosticsNode] representation. The [DiagnosticsNode] representation is +/// also used by debugging tools displaying interactive trees of objects and +/// properties. +/// +/// See also: +/// +/// * [DiagnosticableTreeMixin], which provides a mixin that implements this +/// class. +/// * [Diagnosticable], which should be used instead of this class to provide +/// diagnostics for objects without children. +abstract class DiagnosticableTree extends Diagnosticable { + /// Abstract const constructor. This constructor enables subclasses to provide + /// const constructors so that they can be used in const expressions. + const DiagnosticableTree(); + + /// Returns a one-line detailed description of the object. + /// + /// This description is often somewhat long. This includes the same + /// information given by [toStringDeep], but does not recurse to any children. + /// + /// The [toStringShallow] method can take an argument, which is the string to + /// place between each part obtained from [debugFillProperties]. Passing a + /// string such as `'\n '` will result in a multiline string that indents the + /// properties of the object below its name (as per [toString]). + /// + /// See also: + /// + /// * [toString], for a brief description of the object. + /// * [toStringDeep], for a description of the subtree rooted at this object. + String toStringShallow([String joiner = ', ']) { + final StringBuffer result = new StringBuffer(); + result.write(toString()); + result.write(joiner); + final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); + debugFillProperties(builder); + result.write( + builder.properties.where((DiagnosticsNode n) => !n.hidden).join(joiner), + ); + return result.toString(); + } + + /// Returns a string representation of this node and its descendants. + /// + /// The [toStringDeep] method takes arguments, but those are intended for + /// internal use when recursing to the descendants, and so can be ignored. + /// + /// See also: + /// + /// * [toString], for a brief description of the object but not its children. + /// * [toStringShallow], for a detailed description of the object but not its + /// children. + String toStringDeep([String prefixLineOne = '', String prefixOtherLines]) { + return toDiagnosticsNode().toStringDeep(prefixLineOne, prefixOtherLines); + } + + @override + String toStringShort() => describeIdentity(this); + + @override + DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { + return new _DiagnosticableTreeNode( + name: name, + value: this, + style: style, + ); + } /// Returns a list of [DiagnosticsNode] objects describing this node's /// children. @@ -2126,7 +2148,57 @@ abstract class TreeDiagnosticsMixin implements TreeDiagnostics { /// /// Used by [toStringDeep], [toDiagnosticsNode] and [toStringShallow]. @protected - List debugDescribeChildren() { - return const []; - } + List debugDescribeChildren() => const []; +} + +/// A class that can be used as a mixin that helps dump string and +/// [DiagnosticsNode] representations of trees. +/// +/// This class is identical to DiagnosticableTree except that it can be used as +/// a mixin. +abstract class DiagnosticableTreeMixin implements DiagnosticableTree { + // This class is intended to be used as a mixin, and should not be + // extended directly. + factory DiagnosticableTreeMixin._() => null; + + @override + String toString() { + return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(); + } + + @override + String toStringShallow([String joiner = ', ']) { + final StringBuffer result = new StringBuffer(); + result.write(toStringShort()); + result.write(joiner); + final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); + debugFillProperties(builder); + result.write( + builder.properties.where((DiagnosticsNode n) => !n.hidden).join(joiner), + ); + return result.toString(); + } + + @override + String toStringDeep([String prefixLineOne = '', String prefixOtherLines]) { + return toDiagnosticsNode().toStringDeep(prefixLineOne, prefixOtherLines); + } + + @override + String toStringShort() => describeIdentity(this); + + @override + DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { + return new _DiagnosticableTreeNode( + name: name, + value: this, + style: style, + ); + } + + @override + List debugDescribeChildren() => const []; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { } } diff --git a/packages/flutter/lib/src/gestures/long_press.dart b/packages/flutter/lib/src/gestures/long_press.dart index 4d926eeee4..1e076da9aa 100644 --- a/packages/flutter/lib/src/gestures/long_press.dart +++ b/packages/flutter/lib/src/gestures/long_press.dart @@ -36,5 +36,5 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer { } @override - String toStringShort() => 'long press'; + String get debugDescription => 'long press'; } diff --git a/packages/flutter/lib/src/gestures/monodrag.dart b/packages/flutter/lib/src/gestures/monodrag.dart index ceb38091f0..60f2985cee 100644 --- a/packages/flutter/lib/src/gestures/monodrag.dart +++ b/packages/flutter/lib/src/gestures/monodrag.dart @@ -252,7 +252,7 @@ class VerticalDragGestureRecognizer extends DragGestureRecognizer { double _getPrimaryValueFromOffset(Offset value) => value.dy; @override - String toStringShort() => 'vertical drag'; + String get debugDescription => 'vertical drag'; } /// Recognizes movement in the horizontal direction. @@ -286,7 +286,7 @@ class HorizontalDragGestureRecognizer extends DragGestureRecognizer { double _getPrimaryValueFromOffset(Offset value) => value.dx; @override - String toStringShort() => 'horizontal drag'; + String get debugDescription => 'horizontal drag'; } /// Recognizes movement both horizontally and vertically. @@ -322,5 +322,5 @@ class PanGestureRecognizer extends DragGestureRecognizer { double _getPrimaryValueFromOffset(Offset value) => null; @override - String toStringShort() => 'pan'; + String get debugDescription => 'pan'; } diff --git a/packages/flutter/lib/src/gestures/multidrag.dart b/packages/flutter/lib/src/gestures/multidrag.dart index 9ca6f68c93..ee245bbcee 100644 --- a/packages/flutter/lib/src/gestures/multidrag.dart +++ b/packages/flutter/lib/src/gestures/multidrag.dart @@ -333,7 +333,7 @@ class ImmediateMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Im } @override - String toStringShort() => 'multidrag'; + String get debugDescription => 'multidrag'; } @@ -379,7 +379,7 @@ class HorizontalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_H } @override - String toStringShort() => 'horizontal multidrag'; + String get debugDescription => 'horizontal multidrag'; } @@ -425,7 +425,7 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver } @override - String toStringShort() => 'vertical multidrag'; + String get debugDescription => 'vertical multidrag'; } class _DelayedPointerState extends MultiDragPointerState { @@ -532,5 +532,5 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Dela } @override - String toStringShort() => 'long multidrag'; + String get debugDescription => 'long multidrag'; } diff --git a/packages/flutter/lib/src/gestures/multitap.dart b/packages/flutter/lib/src/gestures/multitap.dart index 8c822bc34f..b13888cf3e 100644 --- a/packages/flutter/lib/src/gestures/multitap.dart +++ b/packages/flutter/lib/src/gestures/multitap.dart @@ -221,7 +221,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { } @override - String toStringShort() => 'double tap'; + String get debugDescription => 'double tap'; } /// TapGesture represents a full gesture resulting from a single tap sequence, @@ -404,5 +404,5 @@ class MultiTapGestureRecognizer extends GestureRecognizer { } @override - String toStringShort() => 'multitap'; + String get debugDescription => 'multitap'; } diff --git a/packages/flutter/lib/src/gestures/recognizer.dart b/packages/flutter/lib/src/gestures/recognizer.dart index 5c74111dc7..0ce4341853 100644 --- a/packages/flutter/lib/src/gestures/recognizer.dart +++ b/packages/flutter/lib/src/gestures/recognizer.dart @@ -35,7 +35,7 @@ typedef T RecognizerCallback(); /// * [GestureDetector], the widget that is used to detect gestures. /// * [debugPrintRecognizerCallbacksTrace], a flag that can be set to help /// debug issues with gesture recognizers. -abstract class GestureRecognizer extends GestureArenaMember with TreeDiagnosticsMixin { +abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableTreeMixin { /// Initializes the gesture recognizer. /// /// The argument is optional and is only used for debug purposes (e.g. in the @@ -73,7 +73,7 @@ abstract class GestureRecognizer extends GestureArenaMember with TreeDiagnostics /// Returns a very short pretty description of the gesture that the /// recognizer looks for, like 'tap' or 'horizontal drag'. - String toStringShort(); + String get debugDescription; /// Invoke a callback provided by the application, catching and logging any /// exceptions. @@ -117,21 +117,10 @@ abstract class GestureRecognizer extends GestureArenaMember with TreeDiagnostics } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('debugOwner', debugOwner, defaultValue: null)); } - - @override - String toString() { - final String name = describeIdentity(this); - List data = []; - debugFillProperties(data); - data = data.where((DiagnosticsNode n) => !n.hidden).toList(); - if (data.isEmpty) - return '$name'; - return '$name(${data.join("; ")})'; - } } /// Base class for gesture recognizers that can only recognize one @@ -375,7 +364,7 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('state', state)); } diff --git a/packages/flutter/lib/src/gestures/scale.dart b/packages/flutter/lib/src/gestures/scale.dart index d49fe9cc76..2fbc170368 100644 --- a/packages/flutter/lib/src/gestures/scale.dart +++ b/packages/flutter/lib/src/gestures/scale.dart @@ -276,5 +276,5 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer { } @override - String toStringShort() => 'scale'; + String get debugDescription => 'scale'; } diff --git a/packages/flutter/lib/src/gestures/tap.dart b/packages/flutter/lib/src/gestures/tap.dart index 2c3e0f6eb2..e281617e98 100644 --- a/packages/flutter/lib/src/gestures/tap.dart +++ b/packages/flutter/lib/src/gestures/tap.dart @@ -158,5 +158,5 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer { } @override - String toStringShort() => 'tap'; + String get debugDescription => 'tap'; } diff --git a/packages/flutter/lib/src/material/button.dart b/packages/flutter/lib/src/material/button.dart index c30e227810..fc53dcefed 100644 --- a/packages/flutter/lib/src/material/button.dart +++ b/packages/flutter/lib/src/material/button.dart @@ -249,7 +249,7 @@ class MaterialButton extends StatefulWidget { _MaterialButtonState createState() => new _MaterialButtonState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('enabled', value: enabled, ifFalse: 'disabled')); } diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index 22c1ea5ad9..ee62f194a3 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -203,7 +203,7 @@ class IconButton extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('icon', icon, showName: false)); description.add(new ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index b004b230b5..8e747ca0fe 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -222,7 +222,7 @@ class InkResponse extends StatefulWidget { _InkResponseState createState() => new _InkResponseState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); final List gestures = []; if (onTap != null) diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 3fac8fc881..8d40ede94e 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -372,7 +372,7 @@ class InputDecorator extends StatelessWidget { final Widget child; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('decoration', decoration)); description.add(new EnumProperty('baseStyle', baseStyle)); @@ -615,7 +615,7 @@ class _AnimatedLabel extends ImplicitlyAnimatedWidget { _AnimatedLabelState createState() => new _AnimatedLabelState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); style?.debugFillProperties(description); } diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index a9f55e2fc4..135ebffef5 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -175,7 +175,7 @@ class Material extends StatefulWidget { _MaterialState createState() => new _MaterialState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('type', type)); description.add(new DoubleProperty('elevation', elevation)); diff --git a/packages/flutter/lib/src/material/mergeable_material.dart b/packages/flutter/lib/src/material/mergeable_material.dart index 47c49a9395..3c3fb5a6b6 100644 --- a/packages/flutter/lib/src/material/mergeable_material.dart +++ b/packages/flutter/lib/src/material/mergeable_material.dart @@ -122,10 +122,10 @@ class MergeableMaterial extends StatefulWidget { final bool hasDividers; @override - String toString() { - return 'MergeableMaterial(' - 'key: $key, mainAxis: $mainAxis, elevation: ${elevation.toStringAsFixed(1)}' - ')'; + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(new EnumProperty('mainAxis', mainAxis)); + properties.add(new DoubleProperty('elevation', elevation.toDouble())); } @override diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index a1638b6936..a3074f58d6 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -61,7 +61,7 @@ abstract class ProgressIndicator extends StatefulWidget { Color _getValueColor(BuildContext context) => valueColor?.value ?? Theme.of(context).accentColor; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new PercentProperty('value', value, showName: false, ifNull: '')); } diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 40eb082834..903c047c72 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -161,7 +161,7 @@ class Slider extends StatefulWidget { _SliderState createState() => new _SliderState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('value', value)); description.add(new DoubleProperty('min', min)); diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index 34379536f2..dce6fe993a 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -99,7 +99,7 @@ class Switch extends StatefulWidget { _SwitchState createState() => new _SwitchState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('value', value: value, ifTrue: 'on', ifFalse: 'off', showName: true)); description.add(new ObjectFlagProperty>('onChanged', onChanged, ifNull: 'disabled')); diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index fda34f35f6..c82f439d8a 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -89,7 +89,7 @@ class Tab extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new StringProperty('text', text, defaultValue: null)); description.add(new DiagnosticsProperty('icon', icon, defaultValue: null)); diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 01e9d77ac2..0f3e01310d 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -176,7 +176,7 @@ class TextField extends StatefulWidget { _TextFieldState createState() => new _TextFieldState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('controller', controller, defaultValue: null)); description.add(new DiagnosticsProperty('focusNode', focusNode, defaultValue: null)); diff --git a/packages/flutter/lib/src/material/theme.dart b/packages/flutter/lib/src/material/theme.dart index 9d8f97cdbf..03c6b0dccc 100644 --- a/packages/flutter/lib/src/material/theme.dart +++ b/packages/flutter/lib/src/material/theme.dart @@ -138,7 +138,7 @@ class Theme extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('data', data, showName: false)); } @@ -235,7 +235,7 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('data', _data, showName: false, defaultValue: null)); } diff --git a/packages/flutter/lib/src/material/toggleable.dart b/packages/flutter/lib/src/material/toggleable.dart index f34db9fce7..baa8680ab6 100644 --- a/packages/flutter/lib/src/material/toggleable.dart +++ b/packages/flutter/lib/src/material/toggleable.dart @@ -303,7 +303,7 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('value', value: value, ifTrue: 'checked', ifFalse: 'unchecked', showName: true)); description.add(new FlagProperty('isInteractive', value: isInteractive, ifTrue: 'enabled', ifFalse: 'disabled', defaultValue: true)); diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index 1883784eb0..b3824bba63 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -86,7 +86,7 @@ class Tooltip extends StatefulWidget { _TooltipState createState() => new _TooltipState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new StringProperty('message', message, showName: false)); description.add(new DoubleProperty('vertical offset', verticalOffset)); diff --git a/packages/flutter/lib/src/painting/box_painter.dart b/packages/flutter/lib/src/painting/box_painter.dart index 125e008e7b..ed910f94ed 100644 --- a/packages/flutter/lib/src/painting/box_painter.dart +++ b/packages/flutter/lib/src/painting/box_painter.dart @@ -1602,23 +1602,19 @@ class BoxDecoration extends Decoration { } @override - DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style: DiagnosticsTreeStyle.whitespace }) { - return new DiagnosticsNode.lazy( - name: name, - value: this, - description: '', - style: style, - emptyBodyDescription: '', - fillProperties: (List properties) { - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new DiagnosticsProperty('image', image, defaultValue: null)); - properties.add(new DiagnosticsProperty('border', border, defaultValue: null)); - properties.add(new DiagnosticsProperty('borderRadius', borderRadius, defaultValue: null)); - properties.add(new IterableProperty('boxShadow', boxShadow, defaultValue: null, style: style)); - properties.add(new DiagnosticsProperty('gradient', gradient, defaultValue: null)); - properties.add(new EnumProperty('shape', shape, defaultValue: BoxShape.rectangle)); - }, - ); + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace + ..emptyBodyDescription = ''; + + properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(new DiagnosticsProperty('image', image, defaultValue: null)); + properties.add(new DiagnosticsProperty('border', border, defaultValue: null)); + properties.add(new DiagnosticsProperty('borderRadius', borderRadius, defaultValue: null)); + properties.add(new IterableProperty('boxShadow', boxShadow, defaultValue: null, style: DiagnosticsTreeStyle.whitespace)); + properties.add(new DiagnosticsProperty('gradient', gradient, defaultValue: null)); + properties.add(new EnumProperty('shape', shape, defaultValue: BoxShape.rectangle)); } @override diff --git a/packages/flutter/lib/src/painting/decoration.dart b/packages/flutter/lib/src/painting/decoration.dart index 0e0a6e290f..cddbe9c67f 100644 --- a/packages/flutter/lib/src/painting/decoration.dart +++ b/packages/flutter/lib/src/painting/decoration.dart @@ -25,11 +25,14 @@ export 'edge_insets.dart' show EdgeInsets; /// shared between boxes; [BoxPainter] objects can cache resources to /// make painting on a particular surface faster. @immutable -abstract class Decoration extends TreeDiagnostics { +abstract class Decoration extends Diagnosticable { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. const Decoration(); + @override + String toStringShort() => '$runtimeType'; + /// In checked mode, throws an exception if the object is not in a /// valid configuration. Otherwise, returns true. /// @@ -80,11 +83,6 @@ abstract class Decoration extends TreeDiagnostics { /// omitted if there is no chance that the painter will change (for example, /// if it is a [BoxDecoration] with definitely no [DecorationImage]). BoxPainter createBoxPainter([VoidCallback onChanged]); - - @override - String toString() { - return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toStringDeep(); - } } /// A stateful class that can paint a particular [Decoration]. diff --git a/packages/flutter/lib/src/painting/flutter_logo.dart b/packages/flutter/lib/src/painting/flutter_logo.dart index 64ae1a628b..78207e2b1e 100644 --- a/packages/flutter/lib/src/painting/flutter_logo.dart +++ b/packages/flutter/lib/src/painting/flutter_logo.dart @@ -212,19 +212,12 @@ class FlutterLogoDecoration extends Decoration { } @override - DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { - return new DiagnosticsNode.lazy( - name: name, - description: '$runtimeType', - value: this, - style: style, - fillProperties: (List properties) { - properties.add(new DiagnosticsNode.message('$lightColor/$darkColor on $textColor')); - properties.add(new EnumProperty('style', this.style)); - if (_inTransition) - properties.add(new DiagnosticsNode.message('transition $_position:$_opacity')); - } - ); + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(new DiagnosticsNode.message('$lightColor/$darkColor on $textColor')); + properties.add(new EnumProperty('style', style)); + if (_inTransition) + properties.add(new DiagnosticsNode.message('transition $_position:$_opacity')); } } diff --git a/packages/flutter/lib/src/painting/text_span.dart b/packages/flutter/lib/src/painting/text_span.dart index 953837d1b6..1e06fda557 100644 --- a/packages/flutter/lib/src/painting/text_span.dart +++ b/packages/flutter/lib/src/painting/text_span.dart @@ -47,7 +47,7 @@ import 'text_style.dart'; /// * [RichText], a widget for finer control of text rendering. /// * [TextPainter], a class for painting [TextSpan] objects on a [Canvas]. @immutable -class TextSpan implements TreeDiagnostics { +class TextSpan extends DiagnosticableTree { /// Creates a [TextSpan] with the given values. /// /// For the object to be useful, at least one of [text] or @@ -248,11 +248,6 @@ class TextSpan implements TreeDiagnostics { return result; } - @override - String toString([String prefix = '']) { - return toStringDeep(prefix, prefix); - } - /// In checked mode, throws an exception if the object is not in a /// valid configuration. Otherwise, returns true. /// @@ -276,7 +271,7 @@ class TextSpan implements TreeDiagnostics { 'TextSpan contains a null child.\n' 'A TextSpan object with a non-null child list should not have any nulls in its child list.\n' 'The full text in question was:\n' - '${toString(" ")}' + '${toStringDeep(' ')}' ); } return true; @@ -317,11 +312,6 @@ class TextSpan implements TreeDiagnostics { return result; } - @override - String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) { - return toDiagnosticsNode().toStringDeep(prefixLineOne, prefixOtherLines); - } - @override bool operator ==(dynamic other) { if (identical(this, other)) @@ -337,37 +327,34 @@ class TextSpan implements TreeDiagnostics { @override int get hashCode => hashValues(style, text, recognizer, hashList(children)); + @override - DiagnosticsNode toDiagnosticsNode({ - String name, - DiagnosticsTreeStyle style: DiagnosticsTreeStyle.whitespace, - }) { - return new DiagnosticsNode.lazy( - name: name, - value: this, - description: '$runtimeType', - style: style, - fillProperties: (List properties) { - // Properties on style are added as if they were properties directly on - // this TextSpan. - if (this.style != null) - this.style.debugFillProperties(properties); + String toStringShort() => '$runtimeType'; - properties.add(new DiagnosticsProperty( - 'recognizer', recognizer, - description: recognizer?.runtimeType?.toString(), - defaultValue: null, - )); + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace; + // Properties on style are added as if they were properties directly on + // this TextSpan. + if (style != null) + style.debugFillProperties(properties); - properties.add(new StringProperty('text', text, showName: false, defaultValue: null)); - if (this.style == null && text == null && children == null) - properties.add(new DiagnosticsNode.message('(empty)')); - }, - getChildren: () { - return children == null ? - [] : - children.map((TextSpan child) => child?.toDiagnosticsNode()).toList(); - }, - ); + properties.add(new DiagnosticsProperty( + 'recognizer', recognizer, + description: recognizer?.runtimeType?.toString(), + defaultValue: null, + )); + + properties.add(new StringProperty('text', text, showName: false, defaultValue: null)); + if (style == null && text == null && children == null) + properties.add(new DiagnosticsNode.message('(empty)')); + } + + @override + List debugDescribeChildren() { + return children == null ? + const [] : + children.map((TextSpan child) => child?.toDiagnosticsNode()).toList(); } } diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index 6a3830b5aa..2c8cdf2b9a 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -131,7 +131,7 @@ import 'basic_types.dart'; /// * [TextSpan], the class that wraps a [TextStyle] for the purposes of /// passing it to a [RichText]. @immutable -class TextStyle extends TreeDiagnostics { +class TextStyle extends Diagnosticable { /// Creates a text style. const TextStyle({ this.inherit: true, @@ -456,24 +456,12 @@ class TextStyle extends TreeDiagnostics { } @override - DiagnosticsNode toDiagnosticsNode({ - String name, - DiagnosticsTreeStyle style: DiagnosticsTreeStyle.singleLine, - }) { - return new DiagnosticsNode.lazy( - name: name, - value: this, - style: style, - description: '$runtimeType', - fillProperties: debugFillProperties, - ); - } - - @override - String toString() => toDiagnosticsNode().toString(); + String toStringShort() => '$runtimeType'; /// Adds all properties prefixing property names with the optional `prefix`. - void debugFillProperties(List properties, { String prefix: '' }) { + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties, { String prefix: '' }) { + super.debugFillProperties(properties); final List styles = []; styles.add(new DiagnosticsProperty('${prefix}color', color, defaultValue: null)); styles.add(new StringProperty('${prefix}family', fontFamily, defaultValue: null, quoted: false)); @@ -548,7 +536,9 @@ class TextStyle extends TreeDiagnostics { final bool styleSpecified = styles.any((DiagnosticsNode n) => !n.hidden); properties.add(new DiagnosticsProperty('${prefix}inherit', inherit, hidden: !styleSpecified && inherit)); - properties.addAll(styles); + for (DiagnosticsNode style in styles) + properties.add(style); + if (!styleSpecified) properties.add(new FlagProperty('inherit', value: inherit, ifTrue: '$prefix', ifFalse: '$prefix')); } diff --git a/packages/flutter/lib/src/rendering/block.dart b/packages/flutter/lib/src/rendering/block.dart index dffd06f3c9..3fe596dad9 100644 --- a/packages/flutter/lib/src/rendering/block.dart +++ b/packages/flutter/lib/src/rendering/block.dart @@ -156,7 +156,7 @@ class RenderListBody extends RenderBox } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('mainAxis', mainAxis)); } diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index e43570981d..4975915271 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -2088,7 +2088,7 @@ abstract class RenderBox extends RenderObject { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('size', _size, ifNull: 'MISSING')); } diff --git a/packages/flutter/lib/src/rendering/debug.dart b/packages/flutter/lib/src/rendering/debug.dart index f3558fdb3e..7a6dd8c827 100644 --- a/packages/flutter/lib/src/rendering/debug.dart +++ b/packages/flutter/lib/src/rendering/debug.dart @@ -179,7 +179,20 @@ class TransformProperty extends DiagnosticsProperty { ); @override - String valueToString() => debugDescribeTransform(value).join('\n'); + String valueToString({ TextTreeConfiguration parentConfiguration }) { + if (parentConfiguration != null && !parentConfiguration.lineBreakProperties) { + // Format the value on a single line to be compatible with the parent's + // style. + final List rows = [ + value.getRow(0), + value.getRow(1), + value.getRow(2), + value.getRow(3), + ]; + return '[${rows.join("; ")}]'; + } + return debugDescribeTransform(value).join('\n'); + } } void _debugDrawDoubleRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) { diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index 093f7fe7c8..994e129975 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -546,7 +546,7 @@ class RenderEditable extends RenderBox { Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Offset.zero & size : null; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('cursorColor', cursorColor)); description.add(new DiagnosticsProperty>('showCursor', showCursor)); diff --git a/packages/flutter/lib/src/rendering/flex.dart b/packages/flutter/lib/src/rendering/flex.dart index 76f9809b05..1934d0543d 100644 --- a/packages/flutter/lib/src/rendering/flex.dart +++ b/packages/flutter/lib/src/rendering/flex.dart @@ -489,11 +489,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin description = []; - node.debugFillProperties(description); - for (DiagnosticsNode line in description) - information.writeln(' $line'); + information.write(' '); + information.write(node.toStringShallow('\n ')); } information.writeln('See also: https://flutter.io/layout/'); addendum = information.toString(); @@ -776,15 +773,15 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin _overflow > 0.0 ? Offset.zero & size : null; @override - String toString() { - String header = super.toString(); + String toStringShort() { + String header = super.toStringShort(); if (_overflow is double && _overflow > 0.0) header += ' OVERFLOWING'; return header; } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('direction', _direction)); description.add(new EnumProperty('mainAxisAlignment', _mainAxisAlignment)); diff --git a/packages/flutter/lib/src/rendering/image.dart b/packages/flutter/lib/src/rendering/image.dart index 61fc2469c8..ab16a63885 100644 --- a/packages/flutter/lib/src/rendering/image.dart +++ b/packages/flutter/lib/src/rendering/image.dart @@ -259,7 +259,7 @@ class RenderImage extends RenderBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('image', image)); description.add(new DoubleProperty('width', width, defaultValue: null)); diff --git a/packages/flutter/lib/src/rendering/layer.dart b/packages/flutter/lib/src/rendering/layer.dart index da73d486e3..a069b02657 100644 --- a/packages/flutter/lib/src/rendering/layer.dart +++ b/packages/flutter/lib/src/rendering/layer.dart @@ -32,7 +32,7 @@ import 'node.dart'; /// /// * [RenderView.compositeFrame], which implements this recomposition protocol /// for painting [RenderObject] trees on the the display. -abstract class Layer extends AbstractNode with TreeDiagnosticsMixin { +abstract class Layer extends AbstractNode with DiagnosticableTreeMixin { /// This layer's parent in the layer tree. /// /// The [parent] of the root node in the layer tree is null. @@ -102,10 +102,10 @@ abstract class Layer extends AbstractNode with TreeDiagnosticsMixin { dynamic debugCreator; @override - String toString() => '${super.toString()}${ owner == null ? " DETACHED" : ""}'; + String toStringShort() => '${super.toStringShort()}${ owner == null ? " DETACHED" : ""}'; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('owner', owner, hidden: parent != null, defaultValue: null)); description.add(new DiagnosticsProperty('creator', debugCreator, defaultValue: null)); @@ -162,7 +162,7 @@ class PictureLayer extends Layer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('paint bounds', canvasBounds)); } @@ -460,7 +460,7 @@ class OffsetLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('offset', offset)); } @@ -488,7 +488,7 @@ class ClipRectLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('clipRect', clipRect)); } @@ -516,7 +516,7 @@ class ClipRRectLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('clipRRect', clipRRect)); } @@ -544,7 +544,7 @@ class ClipPathLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('clipPath', clipPath)); } @@ -596,7 +596,7 @@ class TransformLayer extends OffsetLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new TransformProperty('transform', transform)); } @@ -627,7 +627,7 @@ class OpacityLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new IntProperty('alpha', alpha)); } @@ -667,7 +667,7 @@ class ShaderMaskLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('shader', shader)); description.add(new DiagnosticsProperty('maskRect', maskRect)); @@ -745,7 +745,7 @@ class PhysicalModelLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('clipRRect', clipRRect)); description.add(new DoubleProperty('elevation', elevation)); @@ -854,7 +854,7 @@ class LeaderLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('offset', offset)); description.add(new DiagnosticsProperty('link', link)); @@ -1043,7 +1043,7 @@ class FollowerLayer extends ContainerLayer { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('link', link)); description.add(new TransformProperty('transform', getLastTransform(), defaultValue: null)); diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index f31212e7e6..e76c471d0b 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -17,7 +17,7 @@ import 'layer.dart'; import 'node.dart'; import 'semantics.dart'; -export 'package:flutter/foundation.dart' show FlutterError, InformationCollector, DiagnosticsNode, DiagnosticsProperty, StringProperty, DoubleProperty, EnumProperty, IntProperty; +export 'package:flutter/foundation.dart' show FlutterError, InformationCollector, DiagnosticsNode, DiagnosticsProperty, StringProperty, DoubleProperty, EnumProperty, IntProperty, DiagnosticPropertiesBuilder; export 'package:flutter/gestures.dart' show HitTestEntry, HitTestResult; export 'package:flutter/painting.dart'; @@ -1330,7 +1330,7 @@ class PipelineOwner { /// [RenderObject.markNeedsLayout] so that if a parent has queried the intrinsic /// or baseline information, it gets marked dirty whenever the child's geometry /// changes. -abstract class RenderObject extends AbstractNode with TreeDiagnosticsMixin implements HitTestTarget { +abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin implements HitTestTarget { /// Initializes internal fields for subclasses. RenderObject() { _needsCompositing = isRepaintBoundary || alwaysNeedsCompositing; @@ -2737,7 +2737,7 @@ abstract class RenderObject extends AbstractNode with TreeDiagnosticsMixin imple /// Returns a human understandable name. @override - String toString() { + String toStringShort() { String header = describeIdentity(this); if (_relayoutBoundary != null && _relayoutBoundary != this) { int count = 1; @@ -2757,6 +2757,9 @@ abstract class RenderObject extends AbstractNode with TreeDiagnosticsMixin imple return header; } + @override + String toString() => toStringShort(); + /// Returns a description of the tree rooted at this node. /// If the prefix argument is provided, then every line in the output /// will be prefixed by that string. @@ -2787,7 +2790,7 @@ abstract class RenderObject extends AbstractNode with TreeDiagnosticsMixin imple @protected @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { description.add(new DiagnosticsProperty('creator', debugCreator, defaultValue: null)); description.add(new DiagnosticsProperty('parentData', parentData, tooltip: _debugCanParentUseSize == true ? "can use size" : null)); description.add(new DiagnosticsProperty('constraints', constraints)); diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 441a77fc94..0f64128410 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -169,7 +169,7 @@ abstract class RenderProxyBoxWithHitTestBehavior extends RenderProxyBox { bool hitTestSelf(Offset position) => behavior == HitTestBehavior.opaque; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('behavior', behavior, defaultValue: null)); } @@ -274,7 +274,7 @@ class RenderConstrainedBox extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('additionalConstraints', additionalConstraints)); } @@ -350,7 +350,7 @@ class RenderLimitedBox extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('maxWidth', maxWidth, defaultValue: double.INFINITY)); description.add(new DoubleProperty('maxHeight', maxHeight, defaultValue: double.INFINITY)); @@ -515,7 +515,7 @@ class RenderAspectRatio extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('aspectRatio', aspectRatio)); } @@ -628,7 +628,7 @@ class RenderIntrinsicWidth extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('stepWidth', stepWidth)); description.add(new DoubleProperty('stepHeight', stepHeight)); @@ -766,7 +766,7 @@ class RenderOpacity extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('opacity', opacity)); } @@ -1371,7 +1371,7 @@ class RenderPhysicalModel extends _RenderCustomClip { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('shape', shape)); description.add(new DiagnosticsProperty('borderRadius', borderRadius)); @@ -1485,7 +1485,7 @@ class RenderDecoratedBox extends RenderProxyBox { 'After painting it, the canvas save count was ${context.canvas.getSaveCount()}. ' 'Every call to save() or saveLayer() must be matched by a call to restore().\n' 'The decoration was:\n' - '${decoration.toStringDeep()}\n' + ' $decoration\n' 'The painter was:\n' ' $_painter' ); @@ -1504,7 +1504,7 @@ class RenderDecoratedBox extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(_decoration.toDiagnosticsNode(name: 'decoration')); description.add(new DiagnosticsProperty('configuration', configuration)); @@ -1667,7 +1667,7 @@ class RenderTransform extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new TransformProperty('transform matrix', _transform)); description.add(new DiagnosticsProperty('origin', origin)); @@ -1802,7 +1802,7 @@ class RenderFittedBox extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('fit', fit)); description.add(new DiagnosticsProperty('alignment', alignment)); @@ -1867,7 +1867,7 @@ class RenderFractionalTranslation extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('translation', translation)); description.add(new DiagnosticsProperty('transformHitTests', transformHitTests)); @@ -2337,7 +2337,7 @@ class RenderPointerListener extends RenderProxyBoxWithHitTestBehavior { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); final List listeners = []; if (onPointerDown != null) @@ -2441,7 +2441,7 @@ class RenderRepaintBoundary extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); bool inReleaseMode = true; assert(() { @@ -2552,7 +2552,7 @@ class RenderIgnorePointer extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('ignoring', ignoring)); description.add( @@ -2667,7 +2667,7 @@ class RenderOffstage extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('offstage', offstage)); } @@ -2720,7 +2720,7 @@ class RenderAbsorbPointer extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('absorbing', absorbing)); } @@ -2746,7 +2746,7 @@ class RenderMetaData extends RenderProxyBoxWithHitTestBehavior { dynamic metaData; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('metaData', metaData)); } @@ -2941,7 +2941,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox implements SemanticsA } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); final List gestures = []; if (onTap != null) @@ -3118,7 +3118,7 @@ class RenderExcludeSemantics extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('excluding', excluding)); } @@ -3166,7 +3166,7 @@ class RenderLeaderLayer extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('link', link)); } @@ -3311,7 +3311,7 @@ class RenderFollowerLayer extends RenderProxyBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('link', link)); description.add(new DiagnosticsProperty('showWhenUnlinked', showWhenUnlinked)); diff --git a/packages/flutter/lib/src/rendering/shifted_box.dart b/packages/flutter/lib/src/rendering/shifted_box.dart index c289953ca2..0570c660fb 100644 --- a/packages/flutter/lib/src/rendering/shifted_box.dart +++ b/packages/flutter/lib/src/rendering/shifted_box.dart @@ -177,7 +177,7 @@ class RenderPadding extends RenderShiftedBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('padding', padding)); } @@ -236,7 +236,7 @@ abstract class RenderAligningShiftedBox extends RenderShiftedBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment)); } @@ -366,7 +366,7 @@ class RenderPositionedBox extends RenderAligningShiftedBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('widthFactor', _widthFactor, ifNull: 'expand')); description.add(new DoubleProperty('heightFactor', _heightFactor, ifNull: 'expand')); @@ -479,7 +479,7 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('minWidth', minWidth, ifNull: 'use parent minWidth constraint')); description.add(new DoubleProperty('maxWidth', maxWidth, ifNull: 'use parent maxWidth constraint')); @@ -689,7 +689,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('widthFactor', _widthFactor, ifNull: 'pass-through')); description.add(new DoubleProperty('heightFactor', _heightFactor, ifNull: 'pass-through')); @@ -945,7 +945,7 @@ class RenderBaseline extends RenderShiftedBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('baseline', baseline)); description.add(new EnumProperty('baselineType', baselineType)); diff --git a/packages/flutter/lib/src/rendering/sliver.dart b/packages/flutter/lib/src/rendering/sliver.dart index a0ffadcc04..7ff5fda4d7 100644 --- a/packages/flutter/lib/src/rendering/sliver.dart +++ b/packages/flutter/lib/src/rendering/sliver.dart @@ -467,7 +467,7 @@ class SliverConstraints extends Constraints { /// A sliver can occupy space in several different ways, which is why this class /// contains multiple values. @immutable -class SliverGeometry implements TreeDiagnostics { +class SliverGeometry extends Diagnosticable { /// Creates an object that describes the amount of space occupied by a sliver. /// /// If the [layoutExtent] argument is null, [layoutExtent] defaults to the @@ -620,46 +620,29 @@ class SliverGeometry implements TreeDiagnostics { } @override - String toString() { - return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toStringDeep(); - } + String toStringShort() => '$runtimeType'; @override - String toStringDeep([String prefix = '', String indentPrefix ]) { - return toDiagnosticsNode().toStringDeep(prefix, indentPrefix); - } - - @override - DiagnosticsNode toDiagnosticsNode({ - String name, - DiagnosticsTreeStyle style: DiagnosticsTreeStyle.whitespace, - }) { - return new DiagnosticsNode.lazy( - name: name, - value: this, - description: 'SliverGeometry', - style: style, - emptyBodyDescription: '', - fillProperties: (List properties) { - properties.add(new DoubleProperty('scrollExtent', scrollExtent)); - if (paintExtent > 0.0) { - properties.add(new DoubleProperty('paintExtent', paintExtent, unit : visible ? null : ' but not painting')); - } else if (paintExtent == 0.0) { - if (visible) { - properties.add(new DoubleProperty('paintExtent', paintExtent, unit: visible ? null : ' but visible')); - } - properties.add(new FlagProperty('visible', value: visible, ifFalse: 'hidden')); - } else { - // Negative paintExtent! - properties.add(new DoubleProperty('paintExtent', paintExtent, tooltip: '!')); - } - properties.add(new DoubleProperty('paintOrigin', paintOrigin, defaultValue: 0.0)); - properties.add(new DoubleProperty('layoutExtent', layoutExtent, defaultValue: paintExtent)); - properties.add(new DoubleProperty('maxPaintExtent', maxPaintExtent)); - properties.add(new DoubleProperty('hitTestExtent', hitTestExtent, defaultValue: paintExtent)); - properties.add(new DiagnosticsProperty('hasVisualOverflow', hasVisualOverflow, defaultValue: false)); - properties.add(new DoubleProperty('scrollOffsetCorrection', scrollOffsetCorrection, defaultValue: null)); - }); + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(new DoubleProperty('scrollExtent', scrollExtent)); + if (paintExtent > 0.0) { + properties.add(new DoubleProperty('paintExtent', paintExtent, unit : visible ? null : ' but not painting')); + } else if (paintExtent == 0.0) { + if (visible) { + properties.add(new DoubleProperty('paintExtent', paintExtent, unit: visible ? null : ' but visible')); + } + properties.add(new FlagProperty('visible', value: visible, ifFalse: 'hidden')); + } else { + // Negative paintExtent! + properties.add(new DoubleProperty('paintExtent', paintExtent, tooltip: '!')); + } + properties.add(new DoubleProperty('paintOrigin', paintOrigin, defaultValue: 0.0)); + properties.add(new DoubleProperty('layoutExtent', layoutExtent, defaultValue: paintExtent)); + properties.add(new DoubleProperty('maxPaintExtent', maxPaintExtent)); + properties.add(new DoubleProperty('hitTestExtent', hitTestExtent, defaultValue: paintExtent)); + properties.add(new DiagnosticsProperty('hasVisualOverflow', hasVisualOverflow, defaultValue: false)); + properties.add(new DoubleProperty('scrollOffsetCorrection', scrollOffsetCorrection, defaultValue: null)); } } @@ -1329,7 +1312,7 @@ abstract class RenderSliver extends RenderObject { void handleEvent(PointerEvent event, SliverHitTestEntry entry) { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('geometry', geometry)); } diff --git a/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart b/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart index 95e4f2a45e..64181706c0 100644 --- a/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart +++ b/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart @@ -517,7 +517,7 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsNode.message(firstChild != null ? 'currently live children: ${indexOf(firstChild)} to ${indexOf(lastChild)}' : 'no children current live')); } diff --git a/packages/flutter/lib/src/rendering/sliver_persistent_header.dart b/packages/flutter/lib/src/rendering/sliver_persistent_header.dart index d2c5b380f6..57d007c880 100644 --- a/packages/flutter/lib/src/rendering/sliver_persistent_header.dart +++ b/packages/flutter/lib/src/rendering/sliver_persistent_header.dart @@ -204,7 +204,7 @@ abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObje } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty.lazy('maxExtent', () => maxExtent)); description.add(new DoubleProperty.lazy('child position', () => childMainAxisPosition(child))); @@ -457,7 +457,7 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('effective scroll offset', _effectiveScrollOffset)); } diff --git a/packages/flutter/lib/src/rendering/stack.dart b/packages/flutter/lib/src/rendering/stack.dart index 60974b53f2..abc3c8f5c3 100644 --- a/packages/flutter/lib/src/rendering/stack.dart +++ b/packages/flutter/lib/src/rendering/stack.dart @@ -524,7 +524,7 @@ class RenderStack extends RenderBox Rect describeApproximatePaintClip(RenderObject child) => _hasVisualOverflow ? Offset.zero & size : null; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment)); description.add(new EnumProperty('fit', fit)); @@ -600,7 +600,7 @@ class RenderIndexedStack extends RenderStack { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new IntProperty('index', index)); } diff --git a/packages/flutter/lib/src/rendering/table.dart b/packages/flutter/lib/src/rendering/table.dart index e41542bd72..503ad8e9f1 100644 --- a/packages/flutter/lib/src/rendering/table.dart +++ b/packages/flutter/lib/src/rendering/table.dart @@ -1278,7 +1278,7 @@ class RenderTable extends RenderBox { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('border', border, defaultValue: null)); description.add(new DiagnosticsProperty>('specified column widths', _columnWidths, hidden: _columnWidths.isEmpty)); diff --git a/packages/flutter/lib/src/rendering/view.dart b/packages/flutter/lib/src/rendering/view.dart index 8ff1451201..695b0ef120 100644 --- a/packages/flutter/lib/src/rendering/view.dart +++ b/packages/flutter/lib/src/rendering/view.dart @@ -211,7 +211,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { // call to ${super.debugFillProperties(description)} is omitted because the // root superclasses don't include any interesting information for this // class diff --git a/packages/flutter/lib/src/rendering/viewport.dart b/packages/flutter/lib/src/rendering/viewport.dart index 4e1aff1490..87f823b763 100644 --- a/packages/flutter/lib/src/rendering/viewport.dart +++ b/packages/flutter/lib/src/rendering/viewport.dart @@ -468,7 +468,7 @@ abstract class RenderViewportBase description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('axisDirection', axisDirection)); description.add(new DiagnosticsProperty('offset', offset)); @@ -1045,7 +1045,7 @@ class RenderViewport extends RenderViewportBase description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('anchor', anchor)); } diff --git a/packages/flutter/lib/src/rendering/wrap.dart b/packages/flutter/lib/src/rendering/wrap.dart index 440a229092..272cac74b9 100644 --- a/packages/flutter/lib/src/rendering/wrap.dart +++ b/packages/flutter/lib/src/rendering/wrap.dart @@ -593,7 +593,7 @@ class RenderWrap extends RenderBox with ContainerRenderObjectMixin description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('direction', direction)); description.add(new EnumProperty('alignment', alignment)); diff --git a/packages/flutter/lib/src/services/image_stream.dart b/packages/flutter/lib/src/services/image_stream.dart index 3e9124cc2b..f0249eac31 100644 --- a/packages/flutter/lib/src/services/image_stream.dart +++ b/packages/flutter/lib/src/services/image_stream.dart @@ -70,7 +70,7 @@ typedef void ImageListener(ImageInfo image, bool synchronousCall); /// /// * [ImageProvider], which has an example that includes the use of an /// [ImageStream] in a [Widget]. -class ImageStream { +class ImageStream extends Diagnosticable { /// Create an initially unbound image stream. /// /// Once an [ImageStreamCompleter] is available, call [setCompleter]. @@ -142,24 +142,25 @@ class ImageStream { Object get key => _completer != null ? _completer : this; @override - String toString() { - final StringBuffer result = new StringBuffer(); - result.write('$runtimeType('); - if (_completer == null) { - result.write('unresolved; '); - if (_listeners != null) { - result.write('${_listeners.length} listener${_listeners.length == 1 ? "" : "s" }'); - } else { - result.write('no listeners'); - } - } else { - result.write('${_completer.runtimeType}; '); - final List description = []; - _completer.debugFillDescription(description); - result.write(description.join('; ')); - } - result.write(')'); - return result.toString(); + String toStringShort() => '$runtimeType'; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(new ObjectFlagProperty( + 'completer', + _completer, + ifPresent: _completer?.toStringShort(), + ifNull: 'unresolved', + )); + properties.add(new ObjectFlagProperty>( + 'listeners', + _listeners, + ifPresent: '${_listeners?.length} listener${_listeners?.length == 1 ? "" : "s" }', + ifNull: 'no listeners', + hidden: _completer != null, + )); + _completer?.debugFillProperties(properties); } } @@ -169,7 +170,7 @@ class ImageStream { /// This class is rarely used directly. Generally, an [ImageProvider] subclass /// will return an [ImageStream] and automatically configure it with the right /// [ImageStreamCompleter] when possible. -class ImageStreamCompleter { +class ImageStreamCompleter extends Diagnosticable { final List _listeners = []; ImageInfo _current; @@ -226,22 +227,19 @@ class ImageStreamCompleter { } @override - String toString() { - final List description = []; - debugFillDescription(description); - return '$runtimeType(${description.join("; ")})'; - } + String toStringShort() => '$runtimeType'; /// Accumulates a list of strings describing the object's state. Subclasses /// should override this to have their information included in [toString]. - @protected - @mustCallSuper - void debugFillDescription(List description) { - if (_current == null) - description.add('unresolved'); - else - description.add('$_current'); - description.add('${_listeners.length} listener${_listeners.length == 1 ? "" : "s" }'); + @override + void debugFillProperties(DiagnosticPropertiesBuilder description) { + super.debugFillProperties(description); + description.add(new DiagnosticsProperty('current', _current, ifNull: 'unresolved', showName: false)); + description.add(new ObjectFlagProperty>( + 'listeners', + _listeners, + ifPresent: '${_listeners?.length} listener${_listeners?.length == 1 ? "" : "s" }', + )); } } diff --git a/packages/flutter/lib/src/widgets/animated_cross_fade.dart b/packages/flutter/lib/src/widgets/animated_cross_fade.dart index daec4c2332..46acb8fffd 100644 --- a/packages/flutter/lib/src/widgets/animated_cross_fade.dart +++ b/packages/flutter/lib/src/widgets/animated_cross_fade.dart @@ -215,7 +215,7 @@ class AnimatedCrossFade extends StatefulWidget { _AnimatedCrossFadeState createState() => new _AnimatedCrossFadeState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('crossFadeState', crossFadeState)); description.add(new DiagnosticsProperty('alignment', alignment, defaultValue: FractionalOffset.topCenter)); @@ -352,7 +352,7 @@ class _AnimatedCrossFadeState extends State with TickerProvid } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('crossFadeState', widget.crossFadeState)); description.add(new DiagnosticsProperty('controller', _controller, showName: false)); diff --git a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart index e89960da39..1aad66b9bb 100644 --- a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart +++ b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart @@ -198,7 +198,7 @@ class _AutomaticKeepAliveState extends State { @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('_keepingAlive', value: _keepingAlive, ifTrue: 'keeping subtree alive')); description.add(new DiagnosticsProperty>( diff --git a/packages/flutter/lib/src/widgets/banner.dart b/packages/flutter/lib/src/widgets/banner.dart index bcdb91eea9..8a75f89a00 100644 --- a/packages/flutter/lib/src/widgets/banner.dart +++ b/packages/flutter/lib/src/widgets/banner.dart @@ -207,7 +207,7 @@ class Banner extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new StringProperty('message', message, showName: false)); description.add(new EnumProperty('location', location)); @@ -243,7 +243,7 @@ class CheckedModeBanner extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); String message = 'disabled'; assert(() { diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 70b112e0d5..adfd83f170 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -120,7 +120,7 @@ class Opacity extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('opacity', opacity)); } @@ -421,7 +421,7 @@ class ClipRect extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty>('clipper', clipper, defaultValue: null)); } @@ -476,7 +476,7 @@ class ClipRRect extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('borderRadius', borderRadius, showName: false, defaultValue: null)); description.add(new DiagnosticsProperty>('clipper', clipper, defaultValue: null)); @@ -528,7 +528,7 @@ class ClipOval extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty>('clipper', clipper, defaultValue: null)); } @@ -576,7 +576,7 @@ class ClipPath extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty>('clipper', clipper, defaultValue: null)); } @@ -639,7 +639,7 @@ class PhysicalModel extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('shape', shape)); description.add(new DiagnosticsProperty('borderRadius', borderRadius)); @@ -1077,7 +1077,7 @@ class Padding extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('padding', padding)); } @@ -1154,7 +1154,7 @@ class Align extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment)); description.add(new DoubleProperty('widthFactor', widthFactor, defaultValue: null)); @@ -1254,7 +1254,7 @@ class LayoutId extends ParentDataWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('id', id)); } @@ -1396,7 +1396,7 @@ class SizedBox extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); final bool hidden = width == double.INFINITY && height == double.INFINITY; description.add(new DoubleProperty('width', width, defaultValue: null, hidden: hidden)); @@ -1457,7 +1457,7 @@ class ConstrainedBox extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('constraints', constraints, showName: false)); } @@ -1535,7 +1535,7 @@ class FractionallySizedBox extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment)); description.add(new DoubleProperty('widthFactor', widthFactor, defaultValue: null)); @@ -1603,7 +1603,7 @@ class LimitedBox extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('maxWidth', maxWidth, defaultValue: double.INFINITY)); description.add(new DoubleProperty('maxHeight', maxHeight, defaultValue: double.INFINITY)); @@ -1675,7 +1675,7 @@ class OverflowBox extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment)); description.add(new DoubleProperty('minWidth', minWidth, defaultValue: null)); @@ -1730,7 +1730,7 @@ class SizedOverflowBox extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment)); description.add(new DiagnosticsProperty('size', size, defaultValue: null)); @@ -1764,7 +1764,7 @@ class Offstage extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('offstage', offstage)); } @@ -1838,7 +1838,7 @@ class AspectRatio extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('aspectRatio', aspectRatio)); } @@ -2017,7 +2017,7 @@ class SliverPadding extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('padding', padding)); } @@ -2159,7 +2159,7 @@ class Stack extends MultiChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment)); description.add(new EnumProperty('fit', fit)); @@ -2365,7 +2365,7 @@ class Positioned extends ParentDataWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('left', left, defaultValue: null)); description.add(new DoubleProperty('top', top, defaultValue: null)); @@ -2881,7 +2881,7 @@ class Flexible extends ParentDataWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new IntProperty('flex', flex)); } @@ -3383,7 +3383,7 @@ class RawImage extends LeafRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('image', image)); description.add(new DoubleProperty('width', width, defaultValue: null)); @@ -3541,7 +3541,7 @@ class Listener extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); final List listeners = []; if (onPointerDown != null) @@ -3655,7 +3655,7 @@ class IgnorePointer extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('ignoring', ignoring)); description.add(new DiagnosticsProperty('ignoringSemantics', ignoringSemantics, defaultValue: null)); @@ -3740,7 +3740,7 @@ class MetaData extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('behavior', behavior)); description.add(new DiagnosticsProperty('metaData', metaData)); @@ -3831,7 +3831,7 @@ class Semantics extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('container', container)); description.add(new DiagnosticsProperty('checked', checked, defaultValue: null)); @@ -3922,7 +3922,7 @@ class ExcludeSemantics extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('excluding', excluding)); } diff --git a/packages/flutter/lib/src/widgets/container.dart b/packages/flutter/lib/src/widgets/container.dart index 3f181c9eb1..953311ee80 100644 --- a/packages/flutter/lib/src/widgets/container.dart +++ b/packages/flutter/lib/src/widgets/container.dart @@ -84,7 +84,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); String label; if (position != null) { @@ -360,7 +360,7 @@ class Container extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment, showName: false, defaultValue: null)); description.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index d8a8296dea..46e31ea9a5 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -254,7 +254,7 @@ class EditableText extends StatefulWidget { EditableTextState createState() => new EditableTextState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('controller', controller)); description.add(new DiagnosticsProperty('focusNode', focusNode)); diff --git a/packages/flutter/lib/src/widgets/fade_in_image.dart b/packages/flutter/lib/src/widgets/fade_in_image.dart index 9c93e18e21..d7ae6692fd 100644 --- a/packages/flutter/lib/src/widgets/fade_in_image.dart +++ b/packages/flutter/lib/src/widgets/fade_in_image.dart @@ -460,7 +460,7 @@ class _FadeInImageState extends State with TickerProviderStateMixin } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('phase', _phase)); description.add(new DiagnosticsProperty('pixels', _imageInfo)); diff --git a/packages/flutter/lib/src/widgets/focus_manager.dart b/packages/flutter/lib/src/widgets/focus_manager.dart index d4218e49b8..abd216d793 100644 --- a/packages/flutter/lib/src/widgets/focus_manager.dart +++ b/packages/flutter/lib/src/widgets/focus_manager.dart @@ -129,7 +129,7 @@ class FocusNode extends ChangeNotifier { /// [BuildContext]. /// * [FocusScope], which is a widget that associates a [FocusScopeNode] with /// its location in the tree. -class FocusScopeNode extends Object with TreeDiagnosticsMixin { +class FocusScopeNode extends Object with DiagnosticableTreeMixin { FocusManager _manager; FocusScopeNode _parent; @@ -354,7 +354,7 @@ class FocusScopeNode extends Object with TreeDiagnosticsMixin { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); if (_focus != null) description.add(new DiagnosticsProperty('focus', _focus)); diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index e5bc2b526c..0b9e5f0397 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -428,7 +428,7 @@ class TypeMatcher { /// * [StatelessWidget], for widgets that always build the same way given a /// particular configuration and ambient state. @immutable -abstract class Widget { +abstract class Widget extends DiagnosticableTree { /// Initializes [key] for subclasses. const Widget({ this.key }); @@ -465,33 +465,17 @@ abstract class Widget { Element createElement(); /// A short, textual description of this widget. + @override String toStringShort() { return key == null ? '$runtimeType' : '$runtimeType-$key'; } @override - String toString() { - final String name = toStringShort(); - List data = []; - debugFillProperties(data); - data = data.where((DiagnosticsNode n) => !n.hidden).toList(); - if (data.isEmpty) - return '$name'; - return '$name(${data.join("; ")})'; + void debugFillProperties(DiagnosticPropertiesBuilder description) { + super.debugFillProperties(description); + description.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.dense; } - /// Add additional information to the given description for use by [toString]. - /// - /// This method makes it easier for subclasses to coordinate to provide a - /// high-quality [toString] implementation. The [toString] implementation on - /// the [State] base class calls [debugFillProperties] to collect useful - /// information from subclasses to incorporate into its return value. - /// - /// If you override this, make sure to start your method with a call to - /// `super.debugFillProperties(description)`. - @protected - @mustCallSuper - void debugFillProperties(List description) { } /// Whether the `newWidget` can be used to update an [Element] that currently /// has the `oldWidget` as its configuration. @@ -983,7 +967,7 @@ typedef void StateSetter(VoidCallback fn); /// be read by descendant widgets. /// * [Widget], for an overview of widgets in general. @optionalTypeArgs -abstract class State { +abstract class State extends Diagnosticable { /// The current configuration. /// /// A [State] object's configuration is the corresponding [StatefulWidget] @@ -1368,15 +1352,6 @@ abstract class State { @mustCallSuper void didChangeDependencies() { } - @override - String toString() { - final List allProperties = []; - debugFillProperties(allProperties); - final Iterable properties = - allProperties.where((DiagnosticsNode n) => !n.hidden); - return '${describeIdentity(this)}(${properties.join("; ")})'; - } - /// Add additional properties to the given description used by /// [toDiagnosticsNode], [toString] and [toStringDeep]. /// @@ -1390,11 +1365,11 @@ abstract class State { /// /// See also: /// - /// * [TreeDiagnosticsMixin.debugFillProperties], which provides detailed + /// * [DiagnosticableTree.debugFillProperties], which provides detailed /// best practices for defining diagnostic properties. - @protected - @mustCallSuper - void debugFillProperties(List description) { + @override + void debugFillProperties(DiagnosticPropertiesBuilder description) { + super.debugFillProperties(description); assert(() { description.add(new EnumProperty<_StateLifecycle>('lifecycle state', _debugLifecycleState, defaultValue: _StateLifecycle.ready)); return true; @@ -2522,7 +2497,7 @@ class BuildOwner { /// element. /// * At this point, the element is considered "defunct" and will not be /// incorporated into the tree in the future. -abstract class Element implements BuildContext, TreeDiagnostics { +abstract class Element extends DiagnosticableTree implements BuildContext { /// Creates an element that uses the given widget as its configuration. /// /// Typically called by an override of [Widget.createElement]. @@ -3291,19 +3266,10 @@ abstract class Element implements BuildContext, TreeDiagnostics { } /// A short, textual description of this element. - String toStringShort() { + @override String toStringShort() { return widget != null ? '${widget.toStringShort()}' : '[$runtimeType]'; } - @override - String toString() { - List data = []; - debugFillProperties(data); - data = data.where((DiagnosticsNode n) => !n.hidden).toList(); - final String name = widget != null ? '${widget.runtimeType}' : '[$runtimeType]'; - return '$name(${data.join("; ")})'; - } - /// Add additional properties to the given description used by /// [toDiagnosticsNode], [toString] and [toStringDeep]. /// @@ -3317,40 +3283,30 @@ abstract class Element implements BuildContext, TreeDiagnostics { /// /// See also: /// - /// * [TreeDiagnosticsMixin.debugFillProperties], which provides detailed + /// * [DiagnosticableTree.debugFillProperties], which provides detailed /// best practices for defining diagnostic properties. @protected @mustCallSuper - void debugFillProperties(List description) { + @override + void debugFillProperties(DiagnosticPropertiesBuilder description) { + super.debugFillProperties(description); + description.defaultDiagnosticsTreeStyle= DiagnosticsTreeStyle.dense; description.add(new ObjectFlagProperty('depth', depth, ifNull: 'no depth')); description.add(new ObjectFlagProperty('widget', widget, ifNull: 'no widget')); if (widget != null) { - description.add(new DiagnosticsProperty('key', widget?.key, showName: false, defaultValue: null)); + description.add(new DiagnosticsProperty('key', widget?.key, showName: false, defaultValue: null, hidden: true)); widget.debugFillProperties(description); } description.add(new FlagProperty('dirty', value: dirty, ifTrue: 'dirty')); } - /// A detailed, textual description of this element, includings its children. @override - String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) { - return toDiagnosticsNode().toStringDeep(prefixLineOne, prefixOtherLines); - } - - @override - DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { - return new DiagnosticsNode.lazy( - name: name, - value: this, - getChildren: () { - final List children = []; - visitChildren((Element child) { - children.add(child.toDiagnosticsNode()); - }); - return children; - }, - style: style ?? DiagnosticsTreeStyle.dense, - ); + List debugDescribeChildren() { + final List children = []; + visitChildren((Element child) { + children.add(child.toDiagnosticsNode()); + }); + return children; } /// Returns true if the element has been marked as needing rebuilding. @@ -3493,7 +3449,7 @@ class ErrorWidget extends LeafRenderObjectWidget { RenderBox createRenderObject(BuildContext context) => new RenderErrorBox(message); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new StringProperty('message', message, quoted: false)); } @@ -3774,7 +3730,7 @@ class StatefulElement extends ComponentElement { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty>('state', state, defaultValue: null)); } @@ -4441,7 +4397,7 @@ abstract class RenderObjectElement extends Element { void removeChildRenderObject(covariant RenderObject child); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('renderObject', renderObject, defaultValue: null)); } diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 18c34fd9a3..f9a8aead3d 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -613,12 +613,12 @@ class RawGestureDetectorState extends State { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); if (_recognizers == null) { description.add(new DiagnosticsNode.message('DISPOSED')); } else { - final List gestures = _recognizers.values.map((GestureRecognizer recognizer) => recognizer.toStringShort()).toList(); + final List gestures = _recognizers.values.map((GestureRecognizer recognizer) => recognizer.debugDescription).toList(); if (gestures.isEmpty) gestures.add(''); description.add(new IterableProperty('gestures', gestures)); diff --git a/packages/flutter/lib/src/widgets/icon.dart b/packages/flutter/lib/src/widgets/icon.dart index 8f09cdc2d6..f92a57110a 100644 --- a/packages/flutter/lib/src/widgets/icon.dart +++ b/packages/flutter/lib/src/widgets/icon.dart @@ -114,7 +114,7 @@ class Icon extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('icon', icon, ifNull: '', showName: false)); description.add(new DoubleProperty('size', size, defaultValue: null)); diff --git a/packages/flutter/lib/src/widgets/icon_theme.dart b/packages/flutter/lib/src/widgets/icon_theme.dart index f9732b4f7b..270a4b4abc 100644 --- a/packages/flutter/lib/src/widgets/icon_theme.dart +++ b/packages/flutter/lib/src/widgets/icon_theme.dart @@ -71,7 +71,7 @@ class IconTheme extends InheritedWidget { bool updateShouldNotify(IconTheme old) => data != old.data; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('data', data, showName: false)); } diff --git a/packages/flutter/lib/src/widgets/image.dart b/packages/flutter/lib/src/widgets/image.dart index 9cb93437f9..c531e2037b 100644 --- a/packages/flutter/lib/src/widgets/image.dart +++ b/packages/flutter/lib/src/widgets/image.dart @@ -314,7 +314,7 @@ class Image extends StatefulWidget { _ImageState createState() => new _ImageState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('image', image)); description.add(new DoubleProperty('width', width, defaultValue: null)); @@ -396,7 +396,7 @@ class _ImageState extends State { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('stream', _imageStream)); description.add(new DiagnosticsProperty('pixels', _imageInfo)); diff --git a/packages/flutter/lib/src/widgets/image_icon.dart b/packages/flutter/lib/src/widgets/image_icon.dart index d795f73d26..3618220c6b 100644 --- a/packages/flutter/lib/src/widgets/image_icon.dart +++ b/packages/flutter/lib/src/widgets/image_icon.dart @@ -80,7 +80,7 @@ class ImageIcon extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('image', image, ifNull: '', showName: false)); description.add(new DoubleProperty('size', size, defaultValue: null)); diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 75a6c517b9..1a50ae47a2 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -179,7 +179,7 @@ abstract class ImplicitlyAnimatedWidget extends StatefulWidget { AnimatedWidgetBaseState createState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new IntProperty('duration', duration.inMilliseconds, unit: 'ms')); } @@ -392,7 +392,7 @@ class AnimatedContainer extends ImplicitlyAnimatedWidget { _AnimatedContainerState createState() => new _AnimatedContainerState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', alignment, showName: false, defaultValue: null)); description.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); @@ -439,7 +439,7 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('alignment', _alignment, showName: false, defaultValue: null)); description.add(new DiagnosticsProperty('padding', _padding, defaultValue: null)); @@ -527,7 +527,7 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget { _AnimatedPositionedState createState() => new _AnimatedPositionedState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('left', left, defaultValue: null)); description.add(new DoubleProperty('top', top, defaultValue: null)); @@ -570,7 +570,7 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new ObjectFlagProperty>.has('left', _left)); description.add(new ObjectFlagProperty>.has('top', _top)); @@ -615,7 +615,7 @@ class AnimatedOpacity extends ImplicitlyAnimatedWidget { _AnimatedOpacityState createState() => new _AnimatedOpacityState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('opacity', opacity)); } @@ -668,7 +668,7 @@ class AnimatedDefaultTextStyle extends ImplicitlyAnimatedWidget { _AnimatedDefaultTextStyleState createState() => new _AnimatedDefaultTextStyleState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); style?.debugFillProperties(description); } @@ -749,7 +749,7 @@ class AnimatedPhysicalModel extends ImplicitlyAnimatedWidget { _AnimatedPhysicalModelState createState() => new _AnimatedPhysicalModelState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('shape', shape)); description.add(new DiagnosticsProperty('borderRadius', borderRadius)); diff --git a/packages/flutter/lib/src/widgets/locale_query.dart b/packages/flutter/lib/src/widgets/locale_query.dart index 2e5c74380b..a497da6c81 100644 --- a/packages/flutter/lib/src/widgets/locale_query.dart +++ b/packages/flutter/lib/src/widgets/locale_query.dart @@ -38,7 +38,7 @@ class LocaleQuery extends InheritedWidget { bool updateShouldNotify(LocaleQuery old) => data != old.data; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('data', data, showName: false)); } diff --git a/packages/flutter/lib/src/widgets/media_query.dart b/packages/flutter/lib/src/widgets/media_query.dart index 0ab43c7da9..84d7d54a8d 100644 --- a/packages/flutter/lib/src/widgets/media_query.dart +++ b/packages/flutter/lib/src/widgets/media_query.dart @@ -193,7 +193,7 @@ class MediaQuery extends InheritedWidget { bool updateShouldNotify(MediaQuery old) => data != old.data; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('data', data, showName: false)); } diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index 7ef0a579aa..a4cfb27d4f 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -370,7 +370,7 @@ class OverlayState extends State with TickerProviderStateMixin { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); // TODO(jacobr): use IterableProperty instead as that would // provide a slightly more consistent string summary of the List. diff --git a/packages/flutter/lib/src/widgets/overscroll_indicator.dart b/packages/flutter/lib/src/widgets/overscroll_indicator.dart index d28571e6d8..225277fc09 100644 --- a/packages/flutter/lib/src/widgets/overscroll_indicator.dart +++ b/packages/flutter/lib/src/widgets/overscroll_indicator.dart @@ -98,7 +98,7 @@ class GlowingOverscrollIndicator extends StatefulWidget { _GlowingOverscrollIndicatorState createState() => new _GlowingOverscrollIndicatorState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('axisDirection', axisDirection)); String showDescription; diff --git a/packages/flutter/lib/src/widgets/page_view.dart b/packages/flutter/lib/src/widgets/page_view.dart index 3b9f8e2f8b..6233c52963 100644 --- a/packages/flutter/lib/src/widgets/page_view.dart +++ b/packages/flutter/lib/src/widgets/page_view.dart @@ -495,7 +495,7 @@ class _PageViewState extends State { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('scrollDirection', widget.scrollDirection)); description.add(new FlagProperty('reverse', value: widget.reverse, ifTrue: 'reversed')); diff --git a/packages/flutter/lib/src/widgets/primary_scroll_controller.dart b/packages/flutter/lib/src/widgets/primary_scroll_controller.dart index c91f078ab0..6d16dab5d8 100644 --- a/packages/flutter/lib/src/widgets/primary_scroll_controller.dart +++ b/packages/flutter/lib/src/widgets/primary_scroll_controller.dart @@ -54,7 +54,7 @@ class PrimaryScrollController extends InheritedWidget { bool updateShouldNotify(PrimaryScrollController old) => controller != old.controller; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('controller', controller, ifNull: 'no controller', showName: false)); } diff --git a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart index 5eb977a166..087674bcce 100644 --- a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart +++ b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart @@ -50,7 +50,7 @@ class RawKeyboardListener extends StatefulWidget { _RawKeyboardListenerState createState() => new _RawKeyboardListenerState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('focusNode', focusNode)); } diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 3ee57eee46..b3599840b3 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -379,7 +379,7 @@ class _ModalScopeStatus extends InheritedWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('isCurrent', value: isCurrent, ifTrue: 'active', ifFalse: 'inactive')); description.add(new FlagProperty('canPop', value: canPop, ifTrue: 'can pop')); diff --git a/packages/flutter/lib/src/widgets/scroll_configuration.dart b/packages/flutter/lib/src/widgets/scroll_configuration.dart index 5a735d0d16..f36e21142e 100644 --- a/packages/flutter/lib/src/widgets/scroll_configuration.dart +++ b/packages/flutter/lib/src/widgets/scroll_configuration.dart @@ -112,7 +112,7 @@ class ScrollConfiguration extends InheritedWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('behavior', behavior)); } diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index 6851d7184c..92498230da 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -222,7 +222,7 @@ abstract class ScrollView extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('scrollDirection', scrollDirection)); description.add(new FlagProperty('reverse', value: reverse, ifTrue: 'reversed', showName: true)); @@ -382,7 +382,7 @@ abstract class BoxScrollView extends ScrollView { Widget buildChildLayout(BuildContext context); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); } @@ -675,7 +675,7 @@ class ListView extends BoxScrollView { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DoubleProperty('itemExtent', itemExtent, defaultValue: null)); } diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 8261a92dcb..19f232a80d 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -156,7 +156,7 @@ class Scrollable extends StatefulWidget { ScrollableState createState() => new ScrollableState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('axisDirection', axisDirection)); description.add(new DiagnosticsProperty('physics', physics)); @@ -484,7 +484,7 @@ class ScrollableState extends State with TickerProviderStateMixin } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('position', position)); } diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index a1026d59d5..713e96744a 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -355,7 +355,7 @@ abstract class SliverMultiBoxAdaptorWidget extends RenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('delegate', delegate)); } @@ -935,7 +935,7 @@ class KeepAlive extends ParentDataWidget { bool debugCanApplyOutOfTurn() => keepAlive; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('keepAlive', keepAlive)); } diff --git a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart index 5e26ce0884..2640d38033 100644 --- a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart +++ b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart @@ -140,7 +140,7 @@ class SliverPersistentHeader extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('delegate', delegate)); final List flags = []; @@ -244,7 +244,7 @@ abstract class _SliverPersistentHeaderRenderObjectWidget extends RenderObjectWid _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('delegate', delegate)); } diff --git a/packages/flutter/lib/src/widgets/table.dart b/packages/flutter/lib/src/widgets/table.dart index aea2407a70..51de17f311 100644 --- a/packages/flutter/lib/src/widgets/table.dart +++ b/packages/flutter/lib/src/widgets/table.dart @@ -376,7 +376,7 @@ class TableCell extends ParentDataWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('verticalAlignment', verticalAlignment)); } diff --git a/packages/flutter/lib/src/widgets/text.dart b/packages/flutter/lib/src/widgets/text.dart index a82d525751..ca2599fa50 100644 --- a/packages/flutter/lib/src/widgets/text.dart +++ b/packages/flutter/lib/src/widgets/text.dart @@ -141,7 +141,7 @@ class DefaultTextStyle extends InheritedWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); style?.debugFillProperties(description); } @@ -270,7 +270,7 @@ class Text extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new StringProperty('data', data, showName: false)); style?.debugFillProperties(description); diff --git a/packages/flutter/lib/src/widgets/ticker_provider.dart b/packages/flutter/lib/src/widgets/ticker_provider.dart index 5b22e85301..8ab2d75b17 100644 --- a/packages/flutter/lib/src/widgets/ticker_provider.dart +++ b/packages/flutter/lib/src/widgets/ticker_provider.dart @@ -57,7 +57,7 @@ class TickerMode extends InheritedWidget { bool updateShouldNotify(TickerMode old) => enabled != old.enabled; @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new FlagProperty('mode', value: enabled, ifTrue: 'enabled', ifFalse: 'disabled', showName: true)); } @@ -127,7 +127,7 @@ abstract class SingleTickerProviderStateMixin extends State implements } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); String tickerDescription; if (_ticker != null) { @@ -210,7 +210,7 @@ abstract class TickerProviderStateMixin extends State implements Ticker } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty>( 'tickers', diff --git a/packages/flutter/lib/src/widgets/title.dart b/packages/flutter/lib/src/widgets/title.dart index a4a869c3b5..8634a3194b 100644 --- a/packages/flutter/lib/src/widgets/title.dart +++ b/packages/flutter/lib/src/widgets/title.dart @@ -40,7 +40,7 @@ class Title extends StatelessWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new StringProperty('title', title, defaultValue: null)); description.add(new DiagnosticsProperty('color', color, defaultValue: null)); diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 051978b5c5..ec567f21c1 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -58,7 +58,7 @@ abstract class AnimatedWidget extends StatefulWidget { _AnimatedState createState() => new _AnimatedState(); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new DiagnosticsProperty('animation', listenable)); } diff --git a/packages/flutter/lib/src/widgets/viewport.dart b/packages/flutter/lib/src/widgets/viewport.dart index c76d3a85dd..8873f5a484 100644 --- a/packages/flutter/lib/src/widgets/viewport.dart +++ b/packages/flutter/lib/src/widgets/viewport.dart @@ -116,7 +116,7 @@ class Viewport extends MultiChildRenderObjectWidget { _ViewportElement createElement() => new _ViewportElement(this); @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('axisDirection', axisDirection)); description.add(new DoubleProperty('anchor', anchor)); @@ -239,7 +239,7 @@ class ShrinkWrappingViewport extends MultiChildRenderObjectWidget { } @override - void debugFillProperties(List description) { + void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); description.add(new EnumProperty('axisDirection', axisDirection)); description.add(new DiagnosticsProperty('offset', offset)); diff --git a/packages/flutter/test/foundation/tree_diagnostics_mixin_test.dart b/packages/flutter/test/foundation/diagnostics_test.dart similarity index 96% rename from packages/flutter/test/foundation/tree_diagnostics_mixin_test.dart rename to packages/flutter/test/foundation/diagnostics_test.dart index 99ee58b0d1..88135f8885 100644 --- a/packages/flutter/test/foundation/tree_diagnostics_mixin_test.dart +++ b/packages/flutter/test/foundation/diagnostics_test.dart @@ -6,7 +6,7 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; -class TestTree extends Object with TreeDiagnosticsMixin { +class TestTree extends Object with DiagnosticableTreeMixin { TestTree({ this.name, this.style, @@ -32,8 +32,12 @@ class TestTree extends Object with TreeDiagnosticsMixin { } @override - void debugFillProperties(List properties) { - properties.addAll(this.properties); + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + if (style != null) + properties.defaultDiagnosticsTreeStyle = style; + + for (DiagnosticsNode property in this.properties) + properties.add(property); } } @@ -231,7 +235,9 @@ void main() { style: lastChildStyle, ); - expect(tree, hasAGoodToStringDeep); + if (tree.style != DiagnosticsTreeStyle.singleLine) + expect(tree, hasAGoodToStringDeep); + expect( tree.toDiagnosticsNode(style: style).toStringDeep(), equalsIgnoringHashCodes(golden), @@ -274,29 +280,13 @@ void main() { 'dense', style: DiagnosticsTreeStyle.dense, golden: - 'TestTree#00000\n' - '│stringProperty1: value1\n' - '│doubleProperty1: 42.5\n' - '│roundedProperty: 0.3\n' - '│nullProperty: null\n' - '│\n' - '│\n' - '├child node A: TestTree#00000\n' - '├child node B: TestTree#00000\n' - '││p1: v1\n' - '││p2: v2\n' - '││\n' - '│├child node B1: TestTree#00000\n' - '│├child node B2: TestTree#00000\n' - '││ property1: value1\n' - '│└child node B3: TestTree#00000\n' - '│ \n' - '│ foo: 42\n' - '└child node C: TestTree#00000\n' - ' foo:\n' - ' multi\n' - ' line\n' - ' value!\n', + 'TestTree#00000(stringProperty1: value1, doubleProperty1: 42.5, roundedProperty: 0.3, nullProperty: null, )\n' + '├child node A: TestTree#00000\n' + '├child node B: TestTree#00000(p1: v1, p2: v2)\n' + '│├child node B1: TestTree#00000\n' + '│├child node B2: TestTree#00000(property1: value1)\n' + '│└child node B3: TestTree#00000(, foo: 42)\n' + '└child node C: TestTree#00000(foo: multi\\nline\\nvalue!)\n', ); goldenStyleTest( @@ -365,12 +355,10 @@ void main() { ' ╚═══════════\n', ); - // You would never really want to make everything a leaf child like this - // but you can and still get a readable tree. - // The joint between single and double lines here is a bit clunky - // but we could correct that if there is any real use for this style. + // You would never really want to make everything a transition child like + // this but you can and still get a readable tree. goldenStyleTest( - 'leaf', + 'transition', style: DiagnosticsTreeStyle.transition, golden: 'TestTree#00000:\n' @@ -468,10 +456,7 @@ void main() { ' │ │ property1: value1\n' ' │ │\n' ' │ └─child node B3: TestTree#00000(, foo: 42)\n' - ' └─child node C: TestTree#00000(foo:\n' - ' multi\n' - ' line\n' - ' value!)\n', + ' └─child node C: TestTree#00000(foo: multi\\nline\\nvalue!)\n', ); }); @@ -534,11 +519,8 @@ void main() { ' │ ║ tree property: TestTree#00000:\n' ' │ ║ survived: true\n' ' │ ║ ├child dense child: TestTree#00000\n' - ' │ ║ ├child dense: TestTree#00000\n' - ' │ ║ │ property1: "value1"\n' - ' │ ║ └child node B3: TestTree#00000\n' - ' │ ║ \n' - ' │ ║ foo: 42\n' + ' │ ║ ├child dense: TestTree#00000(property1: "value1")\n' + ' │ ║ └child node B3: TestTree#00000(, foo: 42)\n' ' │ ╚═══════════\n' ' └─child node C: TestTree#00000\n' ' foo:\n' @@ -1296,10 +1278,6 @@ void main() { objectsProperty.toString(), equals('objects: Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), Color(0xffffffff)'), ); - expect( - objectsProperty.toStringDeep(), - equals('objects: Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), Color(0xffffffff)'), - ); final IterableProperty multiLineProperty = new IterableProperty( 'objects', @@ -1327,7 +1305,6 @@ void main() { expect( new TestTree( - name: 'root', properties: [multiLineProperty], ).toStringDeep(), equalsIgnoringHashCodes( @@ -1338,6 +1315,16 @@ void main() { ), ); + expect( + new TestTree( + properties: [objectsProperty, new IntProperty('foo', 42)], + style: DiagnosticsTreeStyle.singleLine, + ).toStringDeep(), + equalsIgnoringHashCodes( + 'TestTree#00000(objects: [Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), Color(0xffffffff)], foo: 42)', + ), + ); + // Iterable with a single entry. Verify that rendering is sensible and that // multi line rendering isn't used even though it is not helpful. final List singleElementList = [const Color.fromARGB(255, 255, 255, 255)]; diff --git a/packages/flutter/test/gestures/recognizer_test.dart b/packages/flutter/test/gestures/recognizer_test.dart index 7246ca438f..6ed13d4ff3 100644 --- a/packages/flutter/test/gestures/recognizer_test.dart +++ b/packages/flutter/test/gestures/recognizer_test.dart @@ -9,7 +9,7 @@ class TestGestureRecognizer extends GestureRecognizer { TestGestureRecognizer({ Object debugOwner }) : super(debugOwner: debugOwner); @override - String toStringShort() => 'toStringShort content'; + String get debugDescription => 'debugDescription content'; @override void addPointer(PointerDownEvent event) { } diff --git a/packages/flutter/test/painting/text_span_test.dart b/packages/flutter/test/painting/text_span_test.dart index 013dbf1aa6..f2dffb12f9 100644 --- a/packages/flutter/test/painting/text_span_test.dart +++ b/packages/flutter/test/painting/text_span_test.dart @@ -49,7 +49,7 @@ void main() { ), ] ); - expect(test.toString(), equals( + expect(test.toStringDeep(), equals( 'TextSpan:\n' ' inherit: true\n' ' size: 10.0\n' diff --git a/packages/flutter/test/rendering/box_test.dart b/packages/flutter/test/rendering/box_test.dart index 35f399cf83..8b2d55625f 100644 --- a/packages/flutter/test/rendering/box_test.dart +++ b/packages/flutter/test/rendering/box_test.dart @@ -76,7 +76,7 @@ void main() { ' parentData: null\n' ' constraints: null\n' ' size: MISSING\n' - ' decoration:\n' + ' decoration: BoxDecoration:\n' ' \n' ' configuration: ImageConfiguration()\n')); @@ -100,7 +100,7 @@ void main() { ' parentData: offset=Offset(10.0, 10.0) (can use size)\n' ' constraints: BoxConstraints(w=780.0, h=580.0)\n' ' size: Size(780.0, 580.0)\n' - ' decoration:\n' + ' decoration: BoxDecoration:\n' ' \n' ' configuration: ImageConfiguration()\n', ), diff --git a/packages/flutter/test/rendering/debug_test.dart b/packages/flutter/test/rendering/debug_test.dart index 4b7bd4c5dd..7845543c27 100644 --- a/packages/flutter/test/rendering/debug_test.dart +++ b/packages/flutter/test/rendering/debug_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; import 'package:test/test.dart'; import 'package:vector_math/vector_math_64.dart'; @@ -30,15 +31,19 @@ void main() { expect(simple.name, equals('transform')); expect(simple.value, same(transform)); expect( - simple.toString(), + simple.toString(parentConfiguration: sparseTextConfiguration), equals( 'transform:\n' - ' [0] 2.0,0.0,0.0,0.0\n' - ' [1] 0.0,2.0,0.0,0.0\n' - ' [2] 0.0,0.0,2.0,0.0\n' - ' [3] 0.0,0.0,0.0,1.0', + ' [0] 2.0,0.0,0.0,0.0\n' + ' [1] 0.0,2.0,0.0,0.0\n' + ' [2] 0.0,0.0,2.0,0.0\n' + ' [3] 0.0,0.0,0.0,1.0', ), ); + expect( + simple.toString(parentConfiguration: singleLineTextConfiguration), + equals('transform: [2.0,0.0,0.0,0.0; 0.0,2.0,0.0,0.0; 0.0,0.0,2.0,0.0; 0.0,0.0,0.0,1.0]'), + ); final TransformProperty nullProperty = new TransformProperty( 'transform', diff --git a/packages/flutter/test/widgets/animated_container_test.dart b/packages/flutter/test/widgets/animated_container_test.dart index 45d729f6b6..8003926ca2 100644 --- a/packages/flutter/test/widgets/animated_container_test.dart +++ b/packages/flutter/test/widgets/animated_container_test.dart @@ -76,7 +76,7 @@ void main() { ' │ parentData: \n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ size: Size(800.0, 600.0)\n' - ' │ decoration:\n' + ' │ decoration: BoxDecoration:\n' ' │ color: Color(0xff0000ff)\n' ' │ configuration: ImageConfiguration(bundle:\n' ' │ PlatformAssetBundle#00000(), devicePixelRatio: 1.0, platform:\n' diff --git a/packages/flutter/test/widgets/container_test.dart b/packages/flutter/test/widgets/container_test.dart index 97869f10e7..a29f72cd56 100644 --- a/packages/flutter/test/widgets/container_test.dart +++ b/packages/flutter/test/widgets/container_test.dart @@ -74,7 +74,7 @@ void main() { ' │ parentData: (can use size)\n' ' │ constraints: BoxConstraints(w=53.0, h=78.0)\n' ' │ size: Size(53.0, 78.0)\n' - ' │ decoration:\n' + ' │ decoration: BoxDecoration:\n' ' │ color: Color(0x7f0000ff)\n' ' │ configuration: ImageConfiguration(bundle:\n' ' │ PlatformAssetBundle#00000(), devicePixelRatio: 1.0, platform:\n' @@ -86,7 +86,7 @@ void main() { ' │ parentData: (can use size)\n' ' │ constraints: BoxConstraints(w=53.0, h=78.0)\n' ' │ size: Size(53.0, 78.0)\n' - ' │ decoration:\n' + ' │ decoration: BoxDecoration:\n' ' │ color: Color(0xff00ff00)\n' ' │ configuration: ImageConfiguration(bundle:\n' ' │ PlatformAssetBundle#00000(), devicePixelRatio: 1.0, platform:\n' @@ -125,7 +125,7 @@ void main() { ' parentData: (can use size)\n' ' constraints: BoxConstraints(w=25.0, h=33.0)\n' ' size: Size(25.0, 33.0)\n' - ' decoration:\n' + ' decoration: BoxDecoration:\n' ' color: Color(0xffffff00)\n' ' configuration: ImageConfiguration(bundle:\n' ' PlatformAssetBundle#00000(), devicePixelRatio: 1.0, platform:\n' diff --git a/packages/flutter/test/widgets/framework_test.dart b/packages/flutter/test/widgets/framework_test.dart index df4f440b7e..df973062b5 100644 --- a/packages/flutter/test/widgets/framework_test.dart +++ b/packages/flutter/test/widgets/framework_test.dart @@ -486,24 +486,23 @@ void main() { expect( element.toStringDeep(), equalsIgnoringHashCodes( - '''Column([GlobalKey#00000]; renderObject: RenderFlex#00000) -├Container() -│└LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#00000 relayoutBoundary=up1) -│ └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2) -├Container([GlobalKey#00000]) -│└LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#00000 relayoutBoundary=up1) -│ └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2) -├Container() -│└Container() -│ └LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#00000 relayoutBoundary=up1) -│ └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2) -├Container([GlobalKey#00000]) -│└LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#00000 relayoutBoundary=up1) -│ └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2) -└Container() - └LimitedBox(maxWidth: 0.0; maxHeight: 0.0; renderObject: RenderLimitedBox#00000 relayoutBoundary=up1) - └ConstrainedBox(BoxConstraints(biggest); renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2) -''', + 'Column-[GlobalKey#00000](renderObject: RenderFlex#00000)\n' + '├Container\n' + '│└LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n' + '│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n' + '├Container-[GlobalKey#00000]\n' + '│└LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n' + '│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n' + '├Container\n' + '│└Container\n' + '│ └LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n' + '│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n' + '├Container-[GlobalKey#00000]\n' + '│└LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n' + '│ └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n' + '└Container\n' + ' └LimitedBox(maxWidth: 0.0, maxHeight: 0.0, renderObject: RenderLimitedBox#00000 relayoutBoundary=up1)\n' + ' └ConstrainedBox(BoxConstraints(biggest), renderObject: RenderConstrainedBox#00000 relayoutBoundary=up2)\n', ), ); }); diff --git a/packages/flutter/test/widgets/global_keys_duplicated_test.dart b/packages/flutter/test/widgets/global_keys_duplicated_test.dart index 1cea63b9a0..442553af9a 100644 --- a/packages/flutter/test/widgets/global_keys_duplicated_test.dart +++ b/packages/flutter/test/widgets/global_keys_duplicated_test.dart @@ -46,8 +46,8 @@ void main() { expect(error, isFlutterError); expect(error.toString(), startsWith('Multiple widgets used the same GlobalKey.\n')); expect(error.toString(), isNot(contains('different widgets that both had the following description'))); - expect(error.toString(), contains('Container()')); - expect(error.toString(), contains('Container([<\'x\'>])')); + expect(error.toString(), contains('Container')); + expect(error.toString(), contains('Container-[<\'x\'>]')); expect(error.toString(), contains('[GlobalObjectKey ${describeIdentity(0)}]')); expect(error.toString(), endsWith('\nA GlobalKey can only be specified on one widget at a time in the widget tree.')); }); @@ -75,7 +75,7 @@ void main() { // We should probably also verify the three other combinations that can be generated... expect(error.toString(), contains('This was determined by noticing that after the widget with the above global key was moved out of its previous parent, that previous parent never updated during this frame, meaning that it either did not update at all or updated before the widget was moved, in either case implying that it still thinks that it should have a child with that global key.')); expect(error.toString(), contains('[GlobalObjectKey ${describeIdentity(0)}]')); - expect(error.toString(), contains('Container()')); + expect(error.toString(), contains('Container')); expect(error.toString(), endsWith('\nA GlobalKey can only be specified on one widget at a time in the widget tree.')); expect(error, isFlutterError); }); diff --git a/packages/flutter/test/widgets/image_test.dart b/packages/flutter/test/widgets/image_test.dart index 5047e23a15..8c9be1fba3 100644 --- a/packages/flutter/test/widgets/image_test.dart +++ b/packages/flutter/test/widgets/image_test.dart @@ -294,12 +294,12 @@ void main() { final TestImageProvider imageProvider = new TestImageProvider(); await tester.pumpWidget(new Image(image: imageProvider)); final State image = tester.state/*State*/(find.byType(Image)); - expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(stream: ImageStream(OneFrameImageStreamCompleter; unresolved; 1 listener); pixels: null)')); + expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(stream: ImageStream(OneFrameImageStreamCompleter, unresolved, 1 listener), pixels: null)')); imageProvider.complete(); await tester.pump(); - expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(stream: ImageStream(OneFrameImageStreamCompleter; [100×100] @ 1.0x; 1 listener); pixels: [100×100] @ 1.0x)')); + expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(stream: ImageStream(OneFrameImageStreamCompleter, [100×100] @ 1.0x, 1 listener), pixels: [100×100] @ 1.0x)')); await tester.pumpWidget(new Container()); - expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(lifecycle state: defunct; not mounted; stream: ImageStream(OneFrameImageStreamCompleter; [100×100] @ 1.0x; 0 listeners); pixels: [100×100] @ 1.0x)')); + expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(lifecycle state: defunct, not mounted, stream: ImageStream(OneFrameImageStreamCompleter, [100×100] @ 1.0x, 0 listeners), pixels: [100×100] @ 1.0x)')); }); testWidgets('Image.memory control test', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/overflow_box_test.dart b/packages/flutter/test/widgets/overflow_box_test.dart index 4309bc3c94..b40b9385a9 100644 --- a/packages/flutter/test/widgets/overflow_box_test.dart +++ b/packages/flutter/test/widgets/overflow_box_test.dart @@ -31,14 +31,14 @@ void main() { }); testWidgets('OverflowBox implements debugFillProperties', (WidgetTester tester) async { - final List properties = []; + final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); const OverflowBox( minWidth: 1.0, maxWidth: 2.0, minHeight: 3.0, maxHeight: 4.0 - ).debugFillProperties(properties); - final List description = properties + ).debugFillProperties(builder); + final List description = builder.properties .where((DiagnosticsNode n) => !n.hidden) .map((DiagnosticsNode n) => n.toString()).toList(); expect(description, [ diff --git a/packages/flutter/test/widgets/table_test.dart b/packages/flutter/test/widgets/table_test.dart index c2bb38fe97..4662a5c16e 100644 --- a/packages/flutter/test/widgets/table_test.dart +++ b/packages/flutter/test/widgets/table_test.dart @@ -526,7 +526,7 @@ void main() { expect( element.toStringDeep(), equalsIgnoringHashCodes( - 'Table([GlobalKey#00000]; renderObject: RenderTable#00000)\n' + 'Table-[GlobalKey#00000](renderObject: RenderTable#00000)\n' '├Text("A")\n' '│└RichText(renderObject: RenderParagraph#00000 relayoutBoundary=up1)\n' '├Text("B")\n'