DepsProvider class
Register on mount; Unregister on unmount.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DepsProvider
Constructors
-
DepsProvider({Key? key, Iterable<
Registerable> ? register, Widget? child, TransitionBuilder? builder}) -
Forks a fresh scope from the nearest ancestor one, or a fresh detached
Deps if there is none. Use DepsProvider.deps to provide an existing
Deps instance instead - e.g. DepsProvider.global for Deps.global
const
-
DepsProvider.deps(Deps? deps, {Key? key, Iterable<
Registerable> ? register, Widget? child, TransitionBuilder? builder}) -
Provide a custom Deps instance that dependencies listed in
registershould be added to. This will also influence the provided scope to thechild/builderby DepsProvider.of and DepsProvider.watch. The caller remains responsible for eventually disposingdeps- unlike the default constructor's forked scope, this widget never disposes it.const - DepsProvider.global({Key? key, Widget? child, TransitionBuilder? builder})
- Provides the Deps.global scope.
-
Every DepsProvider sharing this same
sharedKeyunder the same nearest ancestor scope resolves to one underlying forked Deps - created when the first of them mounts, disposed once the last of them unmounts. Useful for a multi-screen flow that should share one scope without a single common ancestor widget spanning exactly its lifetime.const
Properties
- builder → TransitionBuilder?
-
Alternative to child. A function that builds the child widget.
final
- child → Widget?
-
The widget below this widget in the tree. Use builder alternatively.
If you're going to read the deps in the child widget, you should use
builder or Builder instead to avoid reading stale context.
final
- deps → Deps?
-
See DepsProvider.deps.
nullunless this DepsProvider was created via that constructor (or DepsProvider.global).final - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
register
→ Iterable<
Registerable> ? -
A list of dependencies to register on mount and unregister on unmount.
These dependencies will be bound to this widget, effectively.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
See DepsProvider.shared.
nullunless this DepsProvider was created via that constructor.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< DepsProvider> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
maybeOf(
BuildContext context) → Deps? - Obtain the nearest Deps scope or null if not found.
-
maybeSelect<
T extends Object, R> (BuildContext context, Selector< T, R> selector) → R? -
Like select, but returns
nullinstead of throwing whenTisn't registered. -
maybeWatch<
T extends Object> (BuildContext context) → T? -
Like watch, but returns
nullinstead of throwing whenTisn't registered. -
maybeWatchInstance<
T extends Object> (BuildContext context) → T? -
Like watchInstance, but returns
nullinstead of throwing whenTisn't registered. -
of(
BuildContext context) → Deps - Obtain the nearest Deps scope.
-
select<
T extends Object, R> (BuildContext context, Selector< T, R> selector) → R - Select a derived value - see DepsContext.select.
-
watch<
T extends Object> (BuildContext context) → T - Watch a dependency fully - see DepsContext.watch.
-
watchInstance<
T extends Object> (BuildContext context) → T - Watch a dependency's registration only - see DepsContext.watchInstance.