ServiceContextExtension extension

Provides convenience methods on BuildContext to retrieve, manage, and react to application-wide services and state.

on

Methods

serviceOf<T extends Service>(T create(), {Key? key, ServiceMode mode = .watch}) → T

Available on BuildContext, provided by the ServiceContextExtension extension

Retrieves or lazily creates a service of type T, and binds its lifecycle to this BuildContext's widget lifecycle.
sharedStateOf<T>(T create(), {required Key key, StateMode mode = .watch, dynamic onDispose(T)?}) → ValueState<T>

Available on BuildContext, provided by the ServiceContextExtension extension

Retrieves or lazily creates state shared by key across elements under the same StateScope.
stateOf<T>(T create(), {Key? key, StateMode mode = .watch, dynamic onDispose(T)?}) → ValueState<T>

Available on BuildContext, provided by the ServiceContextExtension extension

Retrieves or lazily creates a state of type T, and binds its ValueState lifecycle to this BuildContext's widget lifecycle.