MultiProvider class

A provider that merges multiple providers into a single linear component tree. It is used to improve readability and reduce boilerplate code of having to nest multiple layers of providers.

As such, we're going from:

Provider<Something>(
  create: (_) => Something(),
  child: Provider<SomethingElse>(
    create: (_) => SomethingElse(),
    child: Provider<AnotherThing>(
      create: (_) => AnotherThing(),
      child: someComponent,
    ),
  ),
),

To:

MultiProvider(
  providers: [
    Provider<Something>(create: (_) => Something()),
    Provider<SomethingElse>(create: (_) => SomethingElse()),
    Provider<AnotherThing>(create: (_) => AnotherThing()),
  ],
  child: someComponent,
)

The component tree representation of the two approaches are identical.

Inheritance

Constructors

MultiProvider({Key? key, required List<SingleChildComponent> providers, Component? child, TransitionBuilder? builder})
Build a tree of providers from a list of SingleChildComponent.

Properties

hashCode int
The hash code for this object.
no setterinherited
key → Key?
Controls how one component replaces another component in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Iterable<Component>
Describes the part of the user interface represented by this component.
inherited
createElement() → _NestedElement
Creates a StatelessElement to manage this component's location in the tree.
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