我试图通过覆盖
debugFillProperties
.
我的问题是,深度似乎有限,此时显示的值是
toString
对象的。
我正试图拥有这样一棵树:
MyClass
+ complexObject: Foo
+ object1: Bar
bar: 42
+ object2: Bar
bar: 0
但我唯一能做到的是:
MyClass
+ complexObject: Foo
object1: Bar(bar: 42)
object2: Bar(bar: 0)
我尝试了以下方法:
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(
DiagnosticsProperty(
'foo',
Foo(),
),
);
}
哪里
Foo
是:
class Foo extends DiagnosticableTree{
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty('object1', Bar(42)));
properties.add(DiagnosticsProperty('object2', Bar(0)));
}
}
class Bar extends Diagnosticable {
final int value;
Bar(this.value);
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty('value', value));
}
}