Minor cleanups (spelling mistakes, unneeded casts)
Rename Outter to Outer. Change _sync() in StatefulComponent to assert the argument type in the signature rather than in the code.
This commit is contained in:
parent
945b5bcd64
commit
0376c35ae4
@ -916,7 +916,7 @@ abstract class StatefulComponent extends Component {
|
|||||||
// because our retainStatefulNodeIfPossible() method returns true,
|
// because our retainStatefulNodeIfPossible() method returns true,
|
||||||
// when _sync is called, our 'old' is actually the new instance that
|
// when _sync is called, our 'old' is actually the new instance that
|
||||||
// we are to copy state from.
|
// we are to copy state from.
|
||||||
void _sync(Widget old, dynamic slot) {
|
void _sync(StatefulComponent old, dynamic slot) {
|
||||||
if (old == null) {
|
if (old == null) {
|
||||||
if (!_isStateInitialized) {
|
if (!_isStateInitialized) {
|
||||||
initState();
|
initState();
|
||||||
@ -925,7 +925,7 @@ abstract class StatefulComponent extends Component {
|
|||||||
}
|
}
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
assert(_isStateInitialized);
|
assert(_isStateInitialized);
|
||||||
assert(!(old as StatefulComponent)._isStateInitialized);
|
assert(!old._isStateInitialized);
|
||||||
syncConstructorArguments(old);
|
syncConstructorArguments(old);
|
||||||
}
|
}
|
||||||
super._sync(old, slot);
|
super._sync(old, slot);
|
||||||
|
@ -21,12 +21,12 @@ class InnerComponent extends StatefulComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OutterContainer extends StatefulComponent {
|
class OuterContainer extends StatefulComponent {
|
||||||
OutterContainer({ this.child });
|
OuterContainer({ this.child });
|
||||||
|
|
||||||
InnerComponent child;
|
InnerComponent child;
|
||||||
|
|
||||||
void syncConstructorArguments(OutterContainer source) {
|
void syncConstructorArguments(OuterContainer source) {
|
||||||
child = source.child;
|
child = source.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,22 +41,22 @@ void main() {
|
|||||||
WidgetTester tester = new WidgetTester();
|
WidgetTester tester = new WidgetTester();
|
||||||
|
|
||||||
InnerComponent inner;
|
InnerComponent inner;
|
||||||
OutterContainer outter;
|
OuterContainer outer;
|
||||||
|
|
||||||
tester.pumpFrame(() {
|
tester.pumpFrame(() {
|
||||||
return new OutterContainer(child: new InnerComponent());
|
return new OuterContainer(child: new InnerComponent());
|
||||||
});
|
});
|
||||||
|
|
||||||
tester.pumpFrame(() {
|
tester.pumpFrame(() {
|
||||||
inner = new InnerComponent();
|
inner = new InnerComponent();
|
||||||
outter = new OutterContainer(child: inner);
|
outer = new OuterContainer(child: inner);
|
||||||
return outter;
|
return outer;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(inner._didInitState, isFalse);
|
expect(inner._didInitState, isFalse);
|
||||||
expect(inner.parent, isNull);
|
expect(inner.parent, isNull);
|
||||||
|
|
||||||
outter.setState(() {});
|
outer.setState(() {});
|
||||||
scheduler.beginFrame(0.0);
|
scheduler.beginFrame(0.0);
|
||||||
|
|
||||||
expect(inner._didInitState, isFalse);
|
expect(inner._didInitState, isFalse);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user