Selector<A, S> class

Shows what builder returns for what selector picks from the A of the provider above, built again only when it picks something else, as Selector0 is. The selector runs each time the value changes; the builder only then.

The first item of the cart, built again only when it changes:

Selector<Cart, String?>(
  selector: (context, cart) => cart.items.firstOrNull,
  builder: (context, first, _) => Text(first ?? 'Empty'),
)
Inheritance

Constructors

Selector({required ValueWidgetBuilder<S> builder, required S selector(BuildContext context, A value), Key? key, ShouldRebuild<S>? shouldRebuild, Widget? child})
Shows what builder returns for what selector picks of the A above.

Properties

builder → ValueWidgetBuilder<S>
Builds what this widget shows from what selector picked.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Tells this widget apart from its siblings; see Key.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selector → S Function(BuildContext context)
Picks what builder builds with, the providers it finds through the context watched.
finalinherited
shouldRebuild → ShouldRebuild<S>?
Whether to build again for what selector picked, given what it picked before; null builds when the two differ.
finalinherited

Methods

createElement() → StatefulElement
Inflates this widget into a new element for the tree.
inherited
createState() → State<Selector0<S>>
Creates the state of a new element; it lives as long as the element.
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