build() This method is called often (think fps + render). It is a required, @override and must return a Widget. Remember that in Flutter all gui is a widget with a child or children, even 'Padding', 'Center'. didUpdateWidget(Widget oldWidget) didUpdateWidget() is called if the parent widget changes and has to rebuild this widget (because it needs to give it different data), but it's being rebuilt with the same runtimeType, then this method is called. This is because Flutter is re-using the state, which is long lived. In this case, required is to initialize some data again, as one would in initState(). If the state's build() method relies on a Stream or other object that can change, unsubscribe from the old object and re-subscribe to the new instance in didUpdateWidget(). tip: This method is basically the replacement for 'initState()' if it is expected the Widget associated with the widgets's state needs to to be rebuilt! Flutter always calls build() after this, so any subsequent further calls to setState is redundant. @override void didUpdateWidget(Widget oldWidget) { if (oldWidget.importantProperty != widget.importantProperty) {
_init();
}
} setState() The 'setState()' method is called often from the Flutter framework itself and from the developer. It is used to notify the framework that "data has changed", and the widget at this build context should be rebuilt. setState() takes a callback which cannot be async. It is for this reason it can be called often as required, because repainting is cheap void updateProfile(String name) { setState(() => this.name = name); } deactivate() This is rarely used. 'deactivate()' is called when State is removed from the tree, but it might be reinserted before the current frame change is finished. This method exists basically because State objects can be