toString()ify more stuff
- truncate pixel values to 1dp since there's really no point being told the Size is 302.98732587287 by 648.28498579187. - describe more Widgets so that debugDumpApp() is more useful. - remove bufferValue from ProgressIndicator (cc @hansmuller) since it's not yet implemented. - half-hearted toString() for ThemeData. There's no point making a complete one, since it would cause line-wrap even on big monitors in debugDumpApp dumps, and you can easily get the actual values from a debugging if that's the issue. - flesh out BoxConstraints.toString() so that fully unconstrained and fully infinite constraints are called out explicitly. I experimented with adding even more special cases, e.g. calling out unconstrained widths with fixed heights, etc, but it made the output less readable. - remove a redundant _updateVariable() in AnimatedContainer (cc @abarth). - add more information to RenderView.toString().
This commit is contained in:
parent
ed189ba957
commit
7c0c1c9609
@ -23,6 +23,8 @@ class IconThemeData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int get hashCode => color.hashCode;
|
int get hashCode => color.hashCode;
|
||||||
|
|
||||||
|
String toString() => '$color';
|
||||||
}
|
}
|
||||||
|
|
||||||
class IconTheme extends InheritedWidget {
|
class IconTheme extends InheritedWidget {
|
||||||
@ -45,6 +47,10 @@ class IconTheme extends InheritedWidget {
|
|||||||
|
|
||||||
bool updateShouldNotify(IconTheme old) => data != old.data;
|
bool updateShouldNotify(IconTheme old) => data != old.data;
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
description.add('$data');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetBundle _initIconBundle() {
|
AssetBundle _initIconBundle() {
|
||||||
@ -63,7 +69,10 @@ class Icon extends StatelessComponent {
|
|||||||
this.type: '',
|
this.type: '',
|
||||||
this.color,
|
this.color,
|
||||||
this.colorFilter
|
this.colorFilter
|
||||||
}) : super(key: key);
|
}) : super(key: key) {
|
||||||
|
assert(size != null);
|
||||||
|
assert(type != null);
|
||||||
|
}
|
||||||
|
|
||||||
final int size;
|
final int size;
|
||||||
final String type;
|
final String type;
|
||||||
@ -108,4 +117,10 @@ class Icon extends StatelessComponent {
|
|||||||
colorFilter: colorFilter
|
colorFilter: colorFilter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
description.add('$type');
|
||||||
|
description.add('size: $size');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,9 @@ class IconButton extends StatelessComponent {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
description.add('$icon');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,12 @@ abstract class MaterialButton extends StatefulComponent {
|
|||||||
final bool enabled;
|
final bool enabled;
|
||||||
final ButtonColor textColor;
|
final ButtonColor textColor;
|
||||||
final GestureTapCallback onPressed;
|
final GestureTapCallback onPressed;
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
if (!enabled)
|
||||||
|
description.add('disabled');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class MaterialButtonState<T extends MaterialButton> extends State<T> {
|
abstract class MaterialButtonState<T extends MaterialButton> extends State<T> {
|
||||||
|
@ -14,15 +14,15 @@ const double _kLinearProgressIndicatorHeight = 6.0;
|
|||||||
const double _kMinCircularProgressIndicatorSize = 15.0;
|
const double _kMinCircularProgressIndicatorSize = 15.0;
|
||||||
const double _kCircularProgressIndicatorStrokeWidth = 3.0;
|
const double _kCircularProgressIndicatorStrokeWidth = 3.0;
|
||||||
|
|
||||||
|
// TODO(hansmuller) implement the support for buffer indicator
|
||||||
|
|
||||||
abstract class ProgressIndicator extends StatefulComponent {
|
abstract class ProgressIndicator extends StatefulComponent {
|
||||||
ProgressIndicator({
|
ProgressIndicator({
|
||||||
Key key,
|
Key key,
|
||||||
this.value,
|
this.value
|
||||||
this.bufferValue
|
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final double value; // Null for non-determinate progress indicator.
|
final double value; // Null for non-determinate progress indicator.
|
||||||
final double bufferValue; // TODO(hansmuller) implement the support for this.
|
|
||||||
|
|
||||||
Color _getBackgroundColor(BuildContext context) => Theme.of(context).primarySwatch[200];
|
Color _getBackgroundColor(BuildContext context) => Theme.of(context).primarySwatch[200];
|
||||||
Color _getValueColor(BuildContext context) => Theme.of(context).primaryColor;
|
Color _getValueColor(BuildContext context) => Theme.of(context).primaryColor;
|
||||||
@ -31,6 +31,11 @@ abstract class ProgressIndicator extends StatefulComponent {
|
|||||||
Widget _buildIndicator(BuildContext context, double performanceValue);
|
Widget _buildIndicator(BuildContext context, double performanceValue);
|
||||||
|
|
||||||
_ProgressIndicatorState createState() => new _ProgressIndicatorState();
|
_ProgressIndicatorState createState() => new _ProgressIndicatorState();
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
description.add('${(value.clamp(0.0, 1.0) * 100.0).toStringAsFixed(1)}%');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ProgressIndicatorState extends State<ProgressIndicator> {
|
class _ProgressIndicatorState extends State<ProgressIndicator> {
|
||||||
@ -72,9 +77,8 @@ class _ProgressIndicatorState extends State<ProgressIndicator> {
|
|||||||
class LinearProgressIndicator extends ProgressIndicator {
|
class LinearProgressIndicator extends ProgressIndicator {
|
||||||
LinearProgressIndicator({
|
LinearProgressIndicator({
|
||||||
Key key,
|
Key key,
|
||||||
double value,
|
double value
|
||||||
double bufferValue
|
}) : super(key: key, value: value);
|
||||||
}) : super(key: key, value: value, bufferValue: bufferValue);
|
|
||||||
|
|
||||||
void _paint(BuildContext context, double performanceValue, Canvas canvas, Size size) {
|
void _paint(BuildContext context, double performanceValue, Canvas canvas, Size size) {
|
||||||
Paint paint = new Paint()
|
Paint paint = new Paint()
|
||||||
@ -120,9 +124,8 @@ class CircularProgressIndicator extends ProgressIndicator {
|
|||||||
|
|
||||||
CircularProgressIndicator({
|
CircularProgressIndicator({
|
||||||
Key key,
|
Key key,
|
||||||
double value,
|
double value
|
||||||
double bufferValue
|
}) : super(key: key, value: value);
|
||||||
}) : super(key: key, value: value, bufferValue: bufferValue);
|
|
||||||
|
|
||||||
void _paint(BuildContext context, double performanceValue, Canvas canvas, Size size) {
|
void _paint(BuildContext context, double performanceValue, Canvas canvas, Size size) {
|
||||||
Paint paint = new Paint()
|
Paint paint = new Paint()
|
||||||
|
@ -281,6 +281,16 @@ class TabLabel {
|
|||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
final String icon;
|
final String icon;
|
||||||
|
|
||||||
|
String toString() {
|
||||||
|
if (text != null && icon != null)
|
||||||
|
return '"$text" ($icon)';
|
||||||
|
if (text != null)
|
||||||
|
return '"$text"';
|
||||||
|
if (icon != null)
|
||||||
|
return '$icon';
|
||||||
|
return 'EMPTY TAB LABEL';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tab extends StatelessComponent {
|
class Tab extends StatelessComponent {
|
||||||
@ -345,6 +355,11 @@ class Tab extends StatelessComponent {
|
|||||||
child: centeredLabel
|
child: centeredLabel
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
description.add('$label');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TabsScrollBehavior extends BoundedBehavior {
|
class _TabsScrollBehavior extends BoundedBehavior {
|
||||||
|
@ -28,4 +28,9 @@ class Theme extends InheritedWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool updateShouldNotify(Theme old) => data != old.data;
|
bool updateShouldNotify(Theme old) => data != old.data;
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
description.add('$data');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,4 +124,6 @@ class ThemeData {
|
|||||||
value = 37 * value + accentColorBrightness.hashCode;
|
value = 37 * value + accentColorBrightness.hashCode;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String toString() => '$primaryColor $brightness etc...';
|
||||||
}
|
}
|
||||||
|
@ -17,4 +17,9 @@ class Title extends StatelessComponent {
|
|||||||
updateTaskDescription(title, Theme.of(context).primaryColor);
|
updateTaskDescription(title, Theme.of(context).primaryColor);
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
description.add('"$title"');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,21 @@ class BoxConstraints extends Constraints {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
String toString() => "BoxConstraints($minWidth<=w<=$maxWidth, $minHeight<=h<=$maxHeight)";
|
String toString() {
|
||||||
|
if (minWidth == double.INFINITY && minHeight == double.INFINITY)
|
||||||
|
return 'BoxConstraints(biggest)';
|
||||||
|
if (minWidth == 0 && maxWidth == double.INFINITY &&
|
||||||
|
minHeight == 0 && maxHeight == double.INFINITY)
|
||||||
|
return 'BoxConstraints(unconstrained)';
|
||||||
|
String describe(double min, double max, String dim) {
|
||||||
|
if (min == max)
|
||||||
|
return '$dim=${min.toStringAsFixed(1)}';
|
||||||
|
return '${min.toStringAsFixed(1)}<=$dim<=${max.toStringAsFixed(1)}';
|
||||||
|
}
|
||||||
|
final String width = describe(minWidth, maxWidth, 'w');
|
||||||
|
final String height = describe(minHeight, maxHeight, 'h');
|
||||||
|
return 'BoxConstraints($width, $height)';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A hit test entry used by [RenderBox]
|
/// A hit test entry used by [RenderBox]
|
||||||
|
@ -132,7 +132,7 @@ class RelativeRect {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
String toString() => "RelativeRect.fromLTRB($left, $top, $right, $bottom)";
|
String toString() => "RelativeRect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parent data for use with [RenderStack]
|
/// Parent data for use with [RenderStack]
|
||||||
|
@ -23,6 +23,8 @@ class ViewConstraints {
|
|||||||
|
|
||||||
/// The orientation of the output surface (aspirational)
|
/// The orientation of the output surface (aspirational)
|
||||||
final int orientation;
|
final int orientation;
|
||||||
|
|
||||||
|
String toString() => '$size';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The root of the render tree
|
/// The root of the render tree
|
||||||
@ -53,7 +55,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
|||||||
ViewConstraints get rootConstraints => _rootConstraints;
|
ViewConstraints get rootConstraints => _rootConstraints;
|
||||||
ViewConstraints _rootConstraints;
|
ViewConstraints _rootConstraints;
|
||||||
void set rootConstraints(ViewConstraints value) {
|
void set rootConstraints(ViewConstraints value) {
|
||||||
if (_rootConstraints == value)
|
if (rootConstraints == value)
|
||||||
return;
|
return;
|
||||||
_rootConstraints = value;
|
_rootConstraints = value;
|
||||||
markNeedsLayout();
|
markNeedsLayout();
|
||||||
@ -80,12 +82,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void performLayout() {
|
void performLayout() {
|
||||||
if (_rootConstraints.orientation != _orientation) {
|
if (rootConstraints.orientation != _orientation) {
|
||||||
if (_orientation != null && child != null)
|
if (_orientation != null && child != null)
|
||||||
child.rotate(oldAngle: _orientation, newAngle: _rootConstraints.orientation, time: timeForRotation);
|
child.rotate(oldAngle: _orientation, newAngle: rootConstraints.orientation, time: timeForRotation);
|
||||||
_orientation = _rootConstraints.orientation;
|
_orientation = rootConstraints.orientation;
|
||||||
}
|
}
|
||||||
_size = _rootConstraints.size;
|
_size = rootConstraints.size;
|
||||||
assert(!_size.isInfinite);
|
assert(!_size.isInfinite);
|
||||||
|
|
||||||
if (child != null)
|
if (child != null)
|
||||||
@ -127,4 +129,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rect get paintBounds => Point.origin & size;
|
Rect get paintBounds => Point.origin & size;
|
||||||
|
|
||||||
|
String debugDescribeSettings(String prefix) => '${prefix}view width: ${ui.view.width} (in device pixels)\n${prefix}view height: ${ui.view.height} (in device pixels)\n${prefix}device pixel ratio: ${ui.view.devicePixelRatio} (device pixels per logical pixel)\n${prefix}root constraints: $rootConstraints (in logical pixels)\n';
|
||||||
|
// call to ${super.debugDescribeSettings(prefix)} is omitted because the root superclasses don't include any interesting information for this class
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,6 @@ class _AnimatedContainerState extends State<AnimatedContainer> {
|
|||||||
|
|
||||||
void _updateAllVariables() {
|
void _updateAllVariables() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_updateVariable(_constraints);
|
|
||||||
_updateVariable(_constraints);
|
_updateVariable(_constraints);
|
||||||
_updateVariable(_decoration);
|
_updateVariable(_decoration);
|
||||||
_updateVariable(_foregroundDecoration);
|
_updateVariable(_foregroundDecoration);
|
||||||
@ -224,4 +223,24 @@ class _AnimatedContainerState extends State<AnimatedContainer> {
|
|||||||
height: _height?.value
|
height: _height?.value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
if (_constraints != null)
|
||||||
|
description.add('has constraints');
|
||||||
|
if (_decoration != null)
|
||||||
|
description.add('has background');
|
||||||
|
if (_foregroundDecoration != null)
|
||||||
|
description.add('has foreground');
|
||||||
|
if (_margin != null)
|
||||||
|
description.add('has margin');
|
||||||
|
if (_padding != null)
|
||||||
|
description.add('has padding');
|
||||||
|
if (_transform != null)
|
||||||
|
description.add('has transform');
|
||||||
|
if (_width != null)
|
||||||
|
description.add('has width');
|
||||||
|
if (_height != null)
|
||||||
|
description.add('has height');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ class ConstrainedBox extends OneChildRenderObjectWidget {
|
|||||||
|
|
||||||
void debugFillDescription(List<String> description) {
|
void debugFillDescription(List<String> description) {
|
||||||
super.debugFillDescription(description);
|
super.debugFillDescription(description);
|
||||||
description.add('constraints: $constraints');
|
description.add('$constraints');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,6 +549,26 @@ class Container extends StatelessComponent {
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
if (constraints != null)
|
||||||
|
description.add('$constraints');
|
||||||
|
if (decoration != null)
|
||||||
|
description.add('has background');
|
||||||
|
if (foregroundDecoration != null)
|
||||||
|
description.add('has foreground');
|
||||||
|
if (margin != null)
|
||||||
|
description.add('margin: $margin');
|
||||||
|
if (padding != null)
|
||||||
|
description.add('padding: $padding');
|
||||||
|
if (transform != null)
|
||||||
|
description.add('has transform');
|
||||||
|
if (width != null)
|
||||||
|
description.add('width: $width');
|
||||||
|
if (height != null)
|
||||||
|
description.add('height: $height');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ class _FocusScope extends InheritedWidget {
|
|||||||
Widget child
|
Widget child
|
||||||
}) : super(key: key, child: child);
|
}) : super(key: key, child: child);
|
||||||
|
|
||||||
final bool scopeFocused;
|
|
||||||
final FocusState focusState;
|
final FocusState focusState;
|
||||||
|
final bool scopeFocused;
|
||||||
|
|
||||||
// These are mutable because we implicitly change them when they're null in
|
// These are mutable because we implicitly change them when they're null in
|
||||||
// certain cases, basically pretending retroactively that we were constructed
|
// certain cases, basically pretending retroactively that we were constructed
|
||||||
@ -61,6 +61,15 @@ class _FocusScope extends InheritedWidget {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugFillDescription(List<String> description) {
|
||||||
|
super.debugFillDescription(description);
|
||||||
|
if (scopeFocused)
|
||||||
|
description.add('this scope has focus');
|
||||||
|
if (focusedScope != null)
|
||||||
|
description.add('focused subscope: $focusedScope');
|
||||||
|
if (focusedWidget != null)
|
||||||
|
description.add('focused widget: $focusedWidget');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Focus extends StatefulComponent {
|
class Focus extends StatefulComponent {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user