StateX<T extends StatefulWidget> constructor

StateX<T extends StatefulWidget>({
  1. StateXController? controller,
  2. bool? runAsync,
  3. bool? useInherited,
  4. bool? printEvents,
  5. bool? debugPrintEvents,
})

With an optional StateXController parameter. Two indicators to use built-in FutureBuilder & InheritedWidget. printEvents deprecated. Use debugPrintEvents instead. debugPrintEvents will print events to console.

Implementation

StateX({
  StateXController? controller,
  bool? runAsync,
  bool? useInherited,
  bool? printEvents,
  bool? debugPrintEvents,
}) {
  // Add to the list of StateX objects present in the app!
  _addToMapOfStates(this);
  _consoleLeadingLine = '===========';

  // A flag whether the built-in FutureBuilder always runs.
  _runAsync = runAsync ?? false;
  // A flag determining whether the built-in InheritedWidget is used or not.
  _useInherited = useInherited ?? false;
  // Show the 'event handler' functions
  _debugPrintEvents = debugPrintEvents ?? printEvents ?? false;
  // Associate the controller to this State object
  _controller = controller;
  // If State prints events, so does its Controllers
  if (_debugPrintEvents) {
    _controller?._debugPrintEvents = _debugPrintEvents;
  }
  // Any subsequent calls to add() will be assigned to stateX.
  add(_controller);
}