Merge pull request #1489 from Hixie/cleanup
Add more debugging information to Widgets.
This commit is contained in:
commit
4913c4fc7d
@ -712,6 +712,11 @@ class DefaultTextStyle extends InheritedWidget {
|
||||
}
|
||||
|
||||
bool updateShouldNotify(DefaultTextStyle old) => style != old.style;
|
||||
|
||||
void debugFillDescription(List<String> 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<String> description) {
|
||||
super.debugFillDescription(description);
|
||||
description.add('"$data"');
|
||||
if (style != null)
|
||||
'$style'.split('\n').forEach(description.add);
|
||||
}
|
||||
}
|
||||
|
||||
class Image extends LeafRenderObjectWidget {
|
||||
|
@ -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<String> data = <String>[];
|
||||
debugFillDescription(data);
|
||||
if (data.isEmpty)
|
||||
return 'name';
|
||||
return 'name(${data.join("; ")})';
|
||||
}
|
||||
|
||||
void debugFillDescription(List<String> description) { }
|
||||
}
|
||||
|
||||
/// RenderObjectWidgets provide the configuration for [RenderObjectElement]s,
|
||||
@ -795,6 +800,8 @@ abstract class Element<T extends Widget> implements BuildContext {
|
||||
description.add('no depth');
|
||||
if (widget == null)
|
||||
description.add('no widget');
|
||||
else
|
||||
widget.debugFillDescription(description);
|
||||
}
|
||||
|
||||
String toStringDeep([String prefixLineOne = '', String prefixOtherLines = '']) {
|
||||
|
@ -318,7 +318,7 @@ class ScrollableViewportState extends ScrollableState<ScrollableViewport> {
|
||||
});
|
||||
}
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user