Selector2<A, B, S> class

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.bar, foo.baz),
  builder: (_, data, __) {
    return Text('${data.item1}  ${data.item2}');
  }
)

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

For generic usage informations, see Consumer.

Inheritance

Constructors

Selector2({Key key, @required ValueWidgetBuilder<S> builder, @required S selector(BuildContext, A, B), 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. [...]

Properties

builder ValueWidgetBuilder<S>
A function that builds a widget tree from child and the last result of selector. [...]
final, inherited
child Widget
A cache of a widget tree that does not depend on the value of selector. [...]
final, inherited
hashCode → int
The hash code for this object.
read-only, 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
selector ValueBuilder<S>
A function that obtains some InheritedWidget and map their content into a new object with only a limited number of properties. [...]
final, inherited

Methods

cloneWithChild(Widget child) Selector0<S>
Clones the current provider with a new child. [...]
inherited
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree. [...]
inherited
createState() → _Selector0State<S>
Creates the mutable state for this widget at a given location in the tree. [...]
inherited
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. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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.debug }) → String
Returns 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 ==(dynamic other) → bool
The equality operator.
inherited