MultiProvider class final
The providers one inside another, the first outermost, around
child: MultiProvider(providers: [Provider(create: …), …], child: …)
for as many nested providers, each a SingleChildWidget without a child
of its own. A provider finds those before it in the list
(context.read in its create), and child finds them all.
With builder, the child is what it returns for child, built below
the providers. A MultiProvider is itself a SingleChildWidget: one may
be in the list of another.
MultiProvider(
providers: [
Provider(create: (context) => const Settings()),
ChangeNotifierProvider(create: (context) => Cart()),
],
child: app,
)
- Inheritance
-
- Object
- Widget
- StatelessWidget
- SingleChildStatelessWidget
- MultiProvider
Constructors
-
MultiProvider({required List<
SingleChildWidget> providers, Key? key, Widget? child, TransitionBuilder? builder}) -
Nests
providersaroundchild, or around whatbuilderreturns.const
Properties
- builder → TransitionBuilder?
-
Builds the child below the providers, from the one given.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Tells this widget apart from its siblings; see Key.
finalinherited
-
providers
→ List<
SingleChildWidget> -
Each without a child.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Widget -
Describes this part of the interface; called when the widget is placed
in the tree, whenever its parent gives it a new widget, and when its
element is marked dirty.
inherited
-
buildWithChild(
BuildContext context, Widget? child) → Widget -
What this widget shows around
child.override -
createElement(
) → StatelessElement -
Inflates this widget into a new element for the tree.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Adds what describes this widget in its element's description
(Element.describe) to
properties, those not worth showing (a default) left out; an override calls this first. A render object widget adds only what its render object does not show. Only Element.describe calls it: a frame never does.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited