OrbitSelector<T extends OrbitStore, S> class
Like OrbitBuilder, but only rebuilds when the value returned by
selector actually changes — useful when a store holds a lot of
state but a given widget only cares about one slice of it. Also
picks up an ancestor OrbitScope<T> automatically, same as
OrbitBuilder.
OrbitSelector<CounterStore, int>(
store: () => CounterStore(),
selector: (store) => store.count,
builder: (context, count) => Text('$count'),
)
Note: keep selector referentially stable across rebuilds where
possible (e.g. a top-level or static function, or a const-friendly
tear-off) rather than a fresh closure built from local state — this
widget doesn't re-run selector on every parent rebuild, only when
the store notifies, so it assumes the same store maps to the same
derived value each time.
By default the selected value is compared with ==; pass equals
for value types that need custom comparison (e.g. deep list/map
equality).
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- OrbitSelector
Constructors
- OrbitSelector({Key? key, required T store(), required S selector(T store), required Widget builder(BuildContext context, S value), bool equals(S previous, S next)?})
-
const
Properties
- builder → Widget Function(BuildContext context, S value)
-
final
- equals → bool Function(S previous, S next)?
-
Custom equality check used to decide whether to rebuild. Defaults
to
==.final - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selector → S Function(T store)
-
final
- store → T Function()
-
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< OrbitSelector< T, S> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent 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.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → 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 ==(
Object other) → bool -
The equality operator.
inherited