From f5834c9abec5b3434f3f3394709d53bb896b07a5 Mon Sep 17 00:00:00 2001 From: Hixie Date: Mon, 5 Oct 2015 10:24:22 -0700 Subject: [PATCH] Add more debugging information to Widgets. Also, fix comment mentioning syncConstructorArguments. --- packages/flutter/lib/src/widgets/basic.dart | 12 ++++++++++++ packages/flutter/lib/src/widgets/framework.dart | 15 +++++++++++---- packages/flutter/lib/src/widgets/scrollable.dart | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index d5dbb44004..22f7d3e6a0 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -712,6 +712,11 @@ class DefaultTextStyle extends InheritedWidget { } bool updateShouldNotify(DefaultTextStyle old) => style != old.style; + + void debugFillDescription(List description) { + super.debugFillDescription(description); + '$style'.split('\n').forEach(description.add); + } } class Text extends StatelessComponent { @@ -738,6 +743,13 @@ class Text extends StatelessComponent { text = new StyledTextSpan(combinedStyle, [text]); return new Paragraph(text: text); } + + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('"$data"'); + if (style != null) + '$style'.split('\n').forEach(description.add); + } } class Image extends LeafRenderObjectWidget { diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index c0cce2b28f..efce9af4ca 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -182,10 +182,15 @@ abstract class Widget { Element createElement(); String toString() { - if (key == null) - return '$runtimeType'; - return '$runtimeType-$key'; - } + final String name = key == null ? '$runtimeType' : '$runtimeType-$key'; + final List data = []; + debugFillDescription(data); + if (data.isEmpty) + return 'name'; + return 'name(${data.join("; ")})'; + } + + void debugFillDescription(List description) { } } /// RenderObjectWidgets provide the configuration for [RenderObjectElement]s, @@ -786,6 +791,8 @@ abstract class Element implements BuildContext { description.add('no depth'); if (widget == null) description.add('no widget'); + else + widget.debugFillDescription(description); } String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) { diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index cf1693a4a1..da4d940a96 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -318,7 +318,7 @@ class ScrollableViewportState extends ScrollableState { }); } void _updateScrollBehaviour() { - // if you don't call this from build() or syncConstructorArguments(), you must call it from setState(). + // if you don't call this from build(), you must call it from setState(). scrollTo(scrollBehavior.updateExtents( contentExtent: _childSize, containerExtent: _viewportSize,