activate method Null safety

  1. @mustCallSuper
void activate()
mustCallSuper">@mustCallSuper

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

@mustCallSuper
void activate() {
  assert(_lifecycleState == _ElementLifecycle.inactive);
  assert(widget != null);
  assert(owner != null);
  assert(depth != null);
  final bool hadDependencies = (_dependencies != null && _dependencies!.isNotEmpty) || _hadUnsatisfiedDependencies;
  _lifecycleState = _ElementLifecycle.active;
  // We unregistered our dependencies in deactivate, but never cleared the list.
  // Since we're going to be reused, let's clear our list now.
  _dependencies?.clear();
  _hadUnsatisfiedDependencies = false;
  _updateInheritance();
  attachNotificationTree();
  if (_dirty) {
    owner!.scheduleBuildFor(this);
  }
  if (hadDependencies) {
    didChangeDependencies();
  }
}