setRootStateX method

void setRootStateX(
  1. StateX<StatefulWidget> state
)
inherited

Important to record the 'root' StateX object. Its InheritedWidget!

Implementation

void setRootStateX(StateX state) {
  // This can only be called once successfully. Subsequent calls are ignored.
  // Important to prefix with the class name to 'share' this as a mixin.
  if (RootState._rootStateX == null && state is AppStateX) {
    // Important to prefix with the class name to 'share' this as a mixin.
    RootState._rootStateX = state;

    // /// It must now add itself to the State objects list.
    // state._addStateX(state);

    // todo: Delete this along with _controllers. Proven hazardous.
    final controller = state.controller;

    if (controller != null) {
      /// Collect all the Controllers to the 'root' State object;
      state._controllers.add(controller);
    }
  }
}