ProxyProvider4<T, T2, T3, T4, R> class

A provider that builds a value based on other providers.

The exposed value is built through create/update, and then passed to InheritedProvider.

As opposed to the create parameter of Provider, update may be called more than once. It will be called once when the widget is mounted, then once whenever any of the InheritedWidget which ProxyProvider depends emits an update.

ProxyProvider comes in different variants such as ProxyProvider2. This only changes the update function, such that it takes a different number of arguments. The 2 in ProxyProvider2 means that update builds its value from 2 other providers.

All variations of update will receive the BuildContext as first parameter, and the previously built value as last parameter.

This previously built value will be null by default, unless create is specified – in which case, it will be the value returned by create.

update must not be null.


While ProxyProvider has built-in support with Provider.of, it works with any InheritedWidget.

As such, ProxyProvider2<Foo, Bar, Baz> is just syntax sugar for:

ProxyProvider<Foo, Baz>(
  update: (context, foo, baz) {
    final bar = Provider.of<Bar>(context);
  child: ...,

And it will also work with other .of patterns, including Scrollable.of, MediaQuery.of, and many more:

ProxyProvider<Foo, Baz>(
  update: (context, foo, _) {
    final mediaQuery = MediaQuery.of(context);
    return Baz(mediaQuery.size);
  child: ...,

This previous example will correctly rebuild Baz when the MediaQuery updates.

See also:



ProxyProvider4({Key key, @Deprecated('Will be removed as part of 4.0.0, use create instead') ValueBuilder<R> initialBuilder, ValueBuilder<R> create, @Deprecated('Will be removed as part of 4.0.0, use update instead') ProxyProviderBuilder4<T, T2, T3, T4, R> builder, @required ProxyProviderBuilder4<T, T2, T3, T4, R> update, UpdateShouldNotify<R> updateShouldNotify, Disposer<R> dispose, Widget child })
Initializes key for subclasses.


builder ProxyProviderBuilder4<T, T2, T3, T4, R>
Builds the value passed to InheritedProvider by combining InheritedWidget. [...]
child Widget
The widget that is below the current Provider widget in the tree.
final, inherited
dispose Disposer<R>
Optionally allows to clean-up resources when the widget is removed from the tree.
final, inherited
hashCode → int
The hash code for this object.
read-only, inherited
initialBuilder ValueBuilder<R>
Builds the initial value passed as previous to didChangeDependencies.
final, inherited
key Key
Controls how one widget replaces another widget in the tree. [...]
final, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
updateShouldNotify UpdateShouldNotify<R>
The UpdateShouldNotify passed to InheritedProvider.
final, inherited


build(BuildContext context, R value) Widget
An equivalent of
cloneWithChild(Widget child) → NumericProxyProvider<T, T2, T3, T4, Void, Void, R>
Clones the current provider with a new child.
createElement() ProxyProviderElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
createState() → _ProxyProviderState<R>
Creates the mutable state for this widget at a given location in the tree.
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
didChangeDependencies(BuildContext context, R previous) → R
Builds the value passed to build by combining InheritedWidget.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
toDiagnosticsNode({String name, DiagnosticsTreeStyle style }) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
toString({DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String
Returns a string representation of this object.
toStringDeep({String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String
Returns a string representation of this node and its descendants. [...]
toStringShallow({String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String
Returns a one-line detailed description of the object. [...]
toStringShort() → String
A short, textual description of this widget.


operator ==(dynamic other) → bool
The equality operator.