StateXController class Get started State Object Controller Testing Event handling
Your 'working' class most concerned with the app's functionality. Add it to a 'StateX' object to associate it with that State object.
dartdoc:
Constructors
-
StateXController([StateX<
StatefulWidget> ? state]) - Optionally supply a State object to 'link' to this object. Thus, assigned as 'current' StateX for this object
-
StateXController.config({StateX<
StatefulWidget> ? state, bool? printEvents}) - Print to console every event handler
Properties
-
appStateX
→ AppStateX<
StatefulWidget> ? -
Reference the App State object
no setteroverride
- calledChangeMetrics → bool
-
Override this method to respond to when the StatefulWidget is recreated.
Called when immediately after initState.
Otherwise called only if a dependency of an InheritedWidget.
Called when the application's UI dimensions change.
For example, when a phone is rotated.
The 'didChangeMetrics' event has already been called in a previous State object
that contains this Controller.
no setter
- dataObject ↔ Object?
-
This is of type Object allowing you
to propagate any class object you wish down the widget tree.
getter/setter pairinherited
- debugPrintEvents ↔ bool
-
debugPrint the 'event handlers'
getter/setter pairinherited
-
firstState
→ State<
StatefulWidget> ? -
Return the first State object
no setterinherited
- hasChangeNotifierImpl → bool
-
A flag. Instantiated Change Notifier
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
no setterinherited
- hasStateListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- identifier → String
-
A unique key is assigned to all State Controllers, State objects
Used in large projects to separate objects into teams.
no setterinherited
- inDebugMode → bool
-
Determines if running in an IDE or in production.
Returns true if the App is under in the Debugger and not production.
no setterinherited
- inFlutterTest → bool
-
Indicate if running under a 'Flutter Test' environment
no setterinherited
- initAsyncCalled → bool
-
Flag indicating initAsync() has been called
no setterinherited
- initStateCalled → bool
-
Flag indicating if initState() was already called
no setter
- inWidgetsFlutterBinding → bool
-
Indicating app is running in the Flutter engine and not in
the
flutter_testframework with TestWidgetsFlutterBinding for exampleno setterinherited - lastContext → BuildContext?
-
Returns the 'latest' context in the App.
no setterinherited
-
lastState
→ State<
StatefulWidget> ? -
Return the 'latest' State object
no setterinherited
- logStateXError ↔ bool
-
Flag whether to log error details or not
getter/setter pairoverride
- printEvents → bool
-
no setterinherited
-
rootState
→ AppStateX<
StatefulWidget> ? -
Returns the 'first' StateX object in the App
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- setBuilderUsed → bool
-
A flag. Noting if the function above is ever used.
no setterinherited
-
state
→ State<
StatefulWidget> ? -
Supply the State object
no setterinherited
-
statex
→ StateX<
StatefulWidget> ? -
Supply the StateX object
no setter
Methods
-
activate(
) → void -
Called when this object is reinserted into the tree after having been
removed via deactivate.
inherited
-
activateState(
covariant State< StatefulWidget> state) → void - Called when this object is reinserted into the tree after having been removed via deactivate. Called when this object is reinserted into the tree after having been removed via deactivate.
-
addState(
StateX< StatefulWidget> ? state) → String - Associate this StateXController to the specified State object to use that State object's functions and features. Returns that State object's unique identifier.
-
addStateListener(
[State< StatefulWidget> ? state]) → bool -
When notified, setState() is called.
inherited
-
catchAsyncError(
Object error) → Future< bool> - Catch it if the initAsync() throws an error WITH GREAT POWER COMES GREAT RESPONSIBILITY Return true to ignore the error, false to continue the error handling
-
deactivate(
) → void -
The framework calls this method whenever it removes this StateX object
from the tree.
inherited
-
deactivateState(
covariant State< StatefulWidget> state) → void - The framework calls this method whenever it removes this StateX object from the tree. The framework calls this method whenever it removes this StateX object from the tree.
-
dependOnInheritedWidget(
BuildContext? context) → bool - Link a widget to an InheritedWidget
-
detachedAppLifecycleState(
) → void -
The Flutter engine is running but any interface is gone.
inherited
-
didChangeAccessibilityFeatures(
) → void -
Called when the current accessibility features have been changed.
inherited
-
didChangeAppLifecycleState(
AppLifecycleState state) → void -
Called when the system puts the app in the background or returns the app to the foreground.
inherited
-
didChangeDependencies(
) → void -
Called when immediately after initState.
Otherwise called only if a dependency of an InheritedWidget.
inherited
-
didChangeLocales(
List< Locale> ? locales) → void -
Called when the system tells the app that the user's locale has changed.
inherited
-
didChangeMetrics(
) → void -
Don't override the original. It's actually implemented there.
Called when the application's UI dimensions change.
For example, when a phone is rotated.
inherited
-
didChangePlatformBrightness(
) → void -
Brightness changed.
inherited
-
didChangeTextScaleFactor(
) → void -
Called when the platform's text scale factor changes.
inherited
-
didChangeViewFocus(
ViewFocusEvent event) → void -
Called whenever the PlatformDispatcher receives a notification that the
focus state on a view has changed.
inherited
-
didHaveMemoryPressure(
) → void -
Called when the system is running low on memory.
inherited
-
didPop(
) → void -
Called when this State is popped off a route.
inherited
-
didPopNext(
) → void -
The top route has been popped off, and this route shows up.
inherited
-
didPopRoute(
) → Future< bool> -
Called when the system tells the app to pop the current route.
For example, on Android, this is called when the user presses
the back button.
inherited
-
didPush(
) → void -
Called when this State is first added to as a Route observer?!
inherited
-
didPushNext(
) → void -
New route has been pushed, and this State object's route is no longer current.
inherited
-
didPushRoute(
String route) → Future< bool> -
Called when the host tells the app to push a new route onto the
navigator.
inherited
-
didPushRouteInformation(
RouteInformation routeInformation) → Future< bool> - Called when the host tells the application to push a new RouteInformation and a restoration state onto the router.
-
didRequestAppExit(
) → Future< AppExitResponse> -
Called when a request is received from the system to exit the application.
Exiting the application can proceed with
AppExitResponse.exit;
Cancel and do not exit the application with
AppExitResponse.cancel;
inherited
-
didUpdateWidget(
covariant StatefulWidget oldWidget) → void -
Override this method to respond to when the StatefulWidget is recreated.
inherited
-
dispose(
) → void - The framework calls this method when this StateX object will never build again. Note: YOU WILL HAVE NO IDEA WHEN THIS WILL RUN in the Framework.
-
disposeSetState(
) → void -
Clean up memory in case not empty
inherited
-
disposeState(
covariant State< StatefulWidget> state) → void - The framework calls this method when this StateX object will never build again. Note: YOU WILL HAVE NO IDEA WHEN THIS WILL RUN in the Framework.
-
forEachState(
void func(State< StatefulWidget> state), {bool? reversed}) → bool -
To externally 'process' through the State objects.
Invokes
funcon each StateX possessed by this object.inherited -
forEachStateX(
void func(StateX< StatefulWidget> state), {bool? reversed}) → bool -
To externally 'process' through the StateX objects.
Invokes
funcon each StateX possessed by this object.inherited -
handleCancelBackGesture(
) → void -
Called when a predictive back gesture is canceled, indicating that no
navigation should occur.
inherited
-
handleCommitBackGesture(
) → void -
Called when a predictive back gesture is finished successfully, indicating
that the current route should be popped.
inherited
-
handleStartBackGesture(
PredictiveBackEvent backEvent) → bool -
Called at the start of a predictive back gesture.
If an observer returns true then that observer, and only that observer,
will be notified of subsequent events in
this same gesture (for example handleUpdateBackGestureProgress, etc.).
inherited
-
handleUpdateBackGestureProgress(
PredictiveBackEvent backEvent) → void -
Called when a predictive back gesture moves.
inherited
-
All views of an application are hidden, either because the application is
about to be paused (on iOS and Android), or because it has been minimized
or placed on a desktop that is no longer visible (on non-web desktop), or
is running in a window or tab that is no longer visible (on the web).
inherited
-
inactiveAppLifecycleState(
) → void -
The application is in an inactive state and is not receiving user input.
inherited
-
initAsync(
) → Future< bool> -
Asynchronous operations must complete successfully.
override
-
initAsyncState(
covariant State< StatefulWidget> state) → Future<bool> -
Called with every StateX associated with this Controller
Initialize any 'time-consuming' operations at the beginning.
Implement any asynchronous operations needed done at start up.
override
-
initState(
) → void -
The framework will call this method exactly once.
Override this method to perform initialization,
override
-
listStates(
List< String> keys) → List<State< StatefulWidget> > -
Returns a List of StateX objects using unique String identifiers.
inherited
-
logErrorDetails(
FlutterErrorDetails details, {bool? force}) → void -
Logs 'every' error as the error count is reset.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyClients(
) → bool - In harmony with Flutter's own API Rebuild the InheritedWidget of the 'closes' InheritedStateX object if any.
-
notifyListeners(
) → bool -
Use the original function name for ChangeNotifier as well
inherited
-
notifyStateListeners(
) → bool -
Call all the registered 'State' listeners.
inherited
-
notifyStates(
) → bool -
inherited
-
ofState<
T extends State< (StatefulWidget> >) → T? -
Retrieve the StateX object of type T
Returns null if not found
inherited
-
onAsyncError(
FlutterErrorDetails details) → void -
initAsync() has failed and a 'error' widget instead will be displayed.
This takes in the snapshot.error details.
override
-
onError(
FlutterErrorDetails details) → void -
Called when the platform's text scale factor changes.
Brightness changed.
Called when the system tells the app that the user's locale has changed.
Either be in the progress of attaching when the engine is first initializing
or after the view being destroyed due to a Navigator pop.
Called when the system is running low on memory.
Determine if its dependencies should be updated.
Called when the system puts the app in the background or returns the app to the foreground.
The application is in an inactive state and is not receiving user input.
All views of an application are hidden, either because the application is
The application is not currently visible to the user, not responding to
user input, and running in the background.
The application is visible and responding to user input.
Either be in the progress of attaching when the engine is first initializing
or after the view being destroyed due to a Navigator pop.
Called whenever the application is reassembled during debugging, for
example during hot reload.
Called when a request is received from the system to exit the application.
Called when the system tells the app to pop the current route.
For example, on Android, this is called when the user presses
the back button.
Called when the host tells the app to push a new route onto the
navigator.
Called when the host tells the application to push a new
RouteInformation and a restoration state onto the router.
Called when this State is first added to as a Route observer?!
New route has been pushed, and this State object's route is no longer current.
Called when this State is popped off a route.
The top route has been popped off, and this route shows up.
Called at the start of a predictive back gesture.
If an observer returns true then that observer, and only that observer,
will be notified of subsequent events in
this same gesture (for example handleUpdateBackGestureProgress, etc.).
override
-
pausedAppLifecycleState(
) → void -
The application is not currently visible to the user, not responding to
user input, and running in the background.
inherited
-
reassemble(
) → void -
Called whenever the application is reassembled during debugging, for
example during hot reload.
inherited
-
removeAllStateListeners(
) → void -
Don't forget to call this method in the appropriate dispose() function!
inherited
-
removeStateListener(
[State< StatefulWidget> ? state]) → bool -
inherited
-
resumedAppLifecycleState(
) → void -
The application is visible and responding to user input.
inherited
-
runInitAsync(
) → bool -
Call initAsync() all the time if returns true.
Conditional calls initAsync() creating a Future with every rebuild
inherited
-
setBuilder(
MaybeBuildWidgetType? builder) → Widget -
Returns a widget from builder assuming the current object is a Listenable
const SizedBox.shrink() otherwise
inherited
-
setState(
VoidCallback fn) → void -
Call a State object's setState()
and notify any listeners
override
-
stateById(
String? id) → State< StatefulWidget> ? -
Returns a State object using a unique String identifier.
inherited
-
stateByType<
T extends State< (StatefulWidget> >) → T? -
Retrieve the State object by type
Returns null if not found
inherited
-
stateInit(
covariant State< StatefulWidget> state) → void - Called by every StateX object associated with it. Override this method to perform initialization,
-
stateOf<
T extends StatefulWidget> () → State< StatefulWidget> ? -
Retrieve the State object by its StatefulWidget. Returns null if not found.
inherited
-
statesById(
List< String> ids) → Map<String, State< StatefulWidget> > -
Returns a Map of StateView objects using unique String identifiers.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateShouldNotify(
covariant InheritedWidget oldWidget) → bool -
Determine if its dependencies should be updated.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited