activate method Null safety

  1. @override
void activate()
override

Transition from the "inactive" to the "active" lifecycle state.

The framework calls this method when a previously deactivated element has been reincorporated into the tree. The framework does not call this method the first time an element becomes active (i.e., from the "initial" lifecycle state). Instead, the framework calls mount in that situation.

See the lifecycle documentation for Element for additional information.

Implementations of this method should start with a call to the inherited method, as in super.activate().

Implementation

@override
void activate() {
  super.activate();
  state.activate();
  // Since the State could have observed the deactivate() and thus disposed of
  // resources allocated in the build method, we have to rebuild the widget
  // so that its State can reallocate its resources.
  assert(_lifecycleState == _ElementLifecycle.active); // otherwise markNeedsBuild is a no-op
  markNeedsBuild();
}