ResourceProvider<T> class
Stateful convenience Widget that manages the lifecycle (creation and disposal) of a resource and makes it available when building this Widget, as well as to all descendant Widgets (see of).
ResourceProvider can be used in two ways - either by subclassing and overriding the createResource,
disposeResource and build methods, or by providing the create
, dispose
and builder
parameters in the
constructor.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- StatefulWatcherWidget
- ResourceProvider
Constructors
-
ResourceProvider({Key? key, required CreateResource<
T> create, required ResourceWidgetBuilder<T> builder, DisposeResource<T> ? dispose}) -
Creates a ResourceProvider with callbacks for creating and disposing (optional) the resource as well as building a
Widget using the resource.
const
-
ResourceProvider.custom({Key? key, CreateResource<
T> ? create, ResourceWidgetBuilder<T> ? builder, DisposeResource<T> ? dispose}) -
Constructor for subclasses that provide implementations for createResource, disposeResource (optional) and
build.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- ref → WatcherRef
-
Object that provides support for watching Listenables within a Widget.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
WatcherContext context, T resource) → Widget - Builds this Widget with the specified resource.
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createResource(
BuildContext context) → T - Creates the resource.
-
createState(
) → WatcherState< StatefulWatcherMixin> -
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
-
disposeResource(
BuildContext context, T resource) → void - Disposes the resource.
-
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}) → 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
-
of<
T> (BuildContext context) → T - Finds the nearest ancestor resource of type T in the Widget tree.