Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: sky/sdk/lib/widgets/widget.dart

Issue 1231623007: Rearrange code in widget.dart StatefulComponent to be more like the order in which it actually runs. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/widget.dart
diff --git a/sky/sdk/lib/widgets/widget.dart b/sky/sdk/lib/widgets/widget.dart
index 042f0dd01c99757afe68271384bb54579f8ae510..e0214a9e424d87c8d44221609300477e86c55bf9 100644
--- a/sky/sdk/lib/widgets/widget.dart
+++ b/sky/sdk/lib/widgets/widget.dart
@@ -532,21 +532,6 @@ abstract class StatefulComponent extends Component {
super._buildIfDirty();
}
- void _sync(Widget old, dynamic slot) {
- assert(!_disqualifiedFromEverAppearingAgain);
- // TODO(ianh): _sync should only be called once when old == null
- if (old == null && !_isStateInitialized) {
- initState();
- _isStateInitialized = true;
- }
- super._sync(old, slot);
- }
-
- Widget syncChild(Widget node, Widget oldNode, dynamic slot) {
- assert(!_disqualifiedFromEverAppearingAgain);
- return super.syncChild(node, oldNode, slot);
- }
-
bool retainStatefulNodeIfPossible(StatefulComponent newNode) {
assert(!_disqualifiedFromEverAppearingAgain);
assert(newNode != null);
@@ -564,6 +549,21 @@ abstract class StatefulComponent extends Component {
return true;
}
+ void _sync(Widget old, dynamic slot) {
+ assert(!_disqualifiedFromEverAppearingAgain);
+ // TODO(ianh): _sync should only be called once when old == null
+ if (old == null && !_isStateInitialized) {
+ initState();
+ _isStateInitialized = true;
+ }
+ super._sync(old, slot);
+ }
+
+ // Stateful components can override initState if they want
+ // to do non-trivial work to initialize state. This is
+ // always called before build().
+ void initState() { }
+
// This is called by retainStatefulNodeIfPossible(), during
// syncChild(), just before _sync() is called. Derived
// classes should override this method to update `this` to
@@ -572,10 +572,10 @@ abstract class StatefulComponent extends Component {
// extending StatefulComponent directly.
void syncFields(Component source);
- // Stateful components can override initState if they want
- // to do non-trivial work to initialize state. This is
- // always called before build().
- void initState() { }
+ Widget syncChild(Widget node, Widget oldNode, dynamic slot) {
+ assert(!_disqualifiedFromEverAppearingAgain);
+ return super.syncChild(node, oldNode, slot);
+ }
void setState(Function fn()) {
assert(!_disqualifiedFromEverAppearingAgain);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698