Selector4<A, B, C, D, S> constructor

Selector4<A, B, C, D, S>({Key key, @required ValueWidgetBuilder<S> builder, @required S selector(BuildContext, A, B, C, D), Widget child })

An equivalent to Consumer that can filter updates by selecting a limited amount of values and prevent rebuild if they don't change.

Selector will obtain a value using Provider.of, then pass that value to selector. That selector callback is then tasked to return an object that contains only the informations needed for builder to complete.

The object returned by selector should be immutable and override operator== such that two objects with the same content are equal, even if they are not identical.

As such, to select multiple values, the easiest solution is to use a "Tuple" from tuple:

Selector<Foo, Tuple2<Bar, Baz>>(
  selector: (_, foo) => Tuple2(, foo.baz),
  builder: (_, data, __) {
    return Text('${data.item1}  ${data.item2}');

In that example, builder will be called again only if or foo.baz changes.

For generic usage informations, see Consumer.


  Key key,
  @required ValueWidgetBuilder<S> builder,
  @required S Function(BuildContext, A, B, C, D) selector,
  Widget child,
})  : assert(selector != null),
        key: key,
        builder: builder,
        selector: (context) => selector(
        child: child,