DepsProvider class

Register on mount; Unregister on unmount.

Inheritance

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 register should be added to. This will also influence the provided scope to the child/builder by DepsProvider.of and DepsProvider.watch. The caller remains responsible for eventually disposing deps - 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.
DepsProvider.shared(Object? sharedKey, {Key? key, Iterable<Registerable>? register, Widget? child, TransitionBuilder? builder})
Every DepsProvider sharing this same sharedKey under 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. null unless 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
sharedKey → Object?
See DepsProvider.shared. null unless 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 null instead of throwing when T isn't registered.
maybeWatch<T extends Object>(BuildContext context) → T?
Like watch, but returns null instead of throwing when T isn't registered.
maybeWatchInstance<T extends Object>(BuildContext context) → T?
Like watchInstance, but returns null instead of throwing when T isn'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.