SignalSelector<T, S> class

============================================================================ SIGNAL SELECTOR (GRANULAR REBUILDS)

Select a part of a signal's value for granular rebuilds.

SignalSelector creates a derived signal that only updates when the selected part of the value changes.

Basic Usage

class User {
  final String name;
  final int age;
  User(this.name, this.age);
}

final user = Signal(User('Alice', 25));

// Only emits when name changes
final nameSignal = SignalSelector(user, (u) => u.name);

nameSignal.addListener(() {
  print('Name changed: ${nameSignal.value}');
});
Inheritance
Available extensions

Constructors

SignalSelector(Signal<T> source, S selector(T value), {String? debugLabel})

Properties

debugLabel String?
Debug label for identification in DevTools.
finalinherited
equals bool Function(S a, S b)?
Custom equality function to determine if value has changed.
finalinherited
guard → S Function(S current, S next)?
Value guard/transformer called before setting a new value.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether this atom has any listeners.
no setterinherited
initialValue → S
The initial value of the atom.
no setterinherited
isDisposed bool
Whether this atom has been disposed.
no setterinherited
onCancel VoidCallback?
Callback invoked when the last listener unsubscribes.
finalinherited
onListen VoidCallback?
Callback invoked when the first listener subscribes.
finalinherited
previousValue → S?
The previous value of the atom (before the last change).
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selector → S Function(T value)
final
source Signal<T>
final
stream Stream<S>
A broadcast stream of value changes.
no setterinherited
val → S
Short alias for the current value.
no setteroverride
value ↔ S
When cold (no listeners), always recompute from source.
getter/setter pairinherited-setteroverride-getter

Methods

add(num amount) → void

Available on Signal<T>, provided by the SignalExtensions extension

Add amount to numeric signal and emit. Alias for increment.
addListener(VoidCallback listener) AtomListener
Adds a listener to be called when the value changes.
inherited
animated({required Widget to(BuildContext context, T value), Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.easeInOut, SlotEffect effect = SlotEffect.fade, DirectionalEffect? directionalEffect}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create an AnimatedSlot with elegant syntax.
bind(NeuronController parent) → T

Available on T, provided by the SignalBinding extension

Registers this notifier to be disposed with parent.
bouncy({required Widget to(BuildContext context, double animatedValue)}) Widget

Available on Signal<T>, provided by the NumericSignalSlotExtensions extension

Create a bouncy spring animation.
debounce(Duration duration) DebouncedSignal<T>

Available on Signal<T>, provided by the SignalHelpers extension

Create a debounced version of this signal.
debounced({required Widget to(BuildContext context, T value), Duration duration = const Duration(milliseconds: 300)}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a debounced slot.
dec([num by = 1]) → void

Available on Signal<T>, provided by the SignalExtensions extension

Short alias for decrement. Decrements numeric signal by by (default 1).
decrement([num by = 1]) → void

Available on Signal<T>, provided by the SignalExtensions extension

Decrement numeric signal.
dispose() → void
Disposes the atom, removing all listeners.
override
distinct() DistinctSignal<T>

Available on Signal<T>, provided by the SignalHelpers extension

Create a distinct version of this signal.
emit(S val) → void
Assigns a new value and notifies listeners if the value changed.
inherited
expandCollapseMorph({double size = 24, Color? color, IconMorphStyle style = IconMorphStyle.rotateScale}) Widget

Available on Signal<bool>, provided by the BooleanMorphExtensions extension

Create an expand/collapse icon morph.
favoriteMorph({double size = 24, Color? activeColor, Color? inactiveColor, IconMorphStyle style = IconMorphStyle.scale}) Widget

Available on Signal<bool>, provided by the BooleanMorphExtensions extension

Create a favorite toggle icon morph.
form({required Widget to(BuildContext context, T value, FormValidationResult validation, bool isFocused), String? validator(T value)?, FormAnimationEffect errorEffect = FormAnimationEffect.shake, FormAnimationEffect successEffect = FormAnimationEffect.pulse, Duration animationDuration = const Duration(milliseconds: 300)}) Widget

Available on Signal<T>, provided by the FormSignalExtensions extension

Create a FormSlot for this signal.
inc([num by = 1]) → void

Available on Signal<T>, provided by the SignalExtensions extension

Short alias for increment. Increments numeric signal by by (default 1).
increment([num by = 1]) → void

Available on Signal<T>, provided by the SignalExtensions extension

Increment numeric signal.
interpolated({required Widget to(BuildContext context, double animatedValue), Duration duration = const Duration(milliseconds: 500), Curve curve = Curves.easeOutCubic}) Widget

Available on Signal<T>, provided by the NumericSignalSlotExtensions extension

Create an AnimatedValueSlot that interpolates the numeric value.
lazy({required Widget to(BuildContext context, T value), Widget placeholder(BuildContext context)?}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a lazy slot that defers building.
memoized({required Widget to(BuildContext context, T value), bool equals(T a, T b)?}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a memoized slot with custom equality.

Available on Signal<bool>, provided by the BooleanMorphExtensions extension

Create a menu/close icon morph (hamburger menu).
morph({required MorphableWidget morphBuilder(BuildContext context, T value), MorphConfig config = const MorphConfig(), VoidCallback? onMorphStart, VoidCallback? onMorphComplete}) Widget

Available on Signal<T>, provided by the MorphSignalExtensions extension

Create a MorphSlot for this signal.
morphIcon({required IconData iconBuilder(T value), double size = 24, Color? color, IconMorphStyle style = IconMorphStyle.crossFade, Duration duration = const Duration(milliseconds: 300)}) Widget

Available on Signal<T>, provided by the MorphSignalExtensions extension

Create an IconMorphSlot for this signal.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Manually notifies all listeners.
inherited
onActive() → void
Subscribe to source when first listener is added.
override
onInactive() → void
Unsubscribe from source when last listener is removed.
override
persist(SignalPersistence<T> persistence) PersistentSignal<T>

Available on Signal<T>, provided by the SignalHelpers extension

Create a persistent version of this signal.
pipeTo(Signal<T> target) StreamSubscription<T>

Available on Signal<T>, provided by the SignalExtensions extension

Pipe values to another signal.
playPauseMorph({double size = 24, Color? color, IconMorphStyle style = IconMorphStyle.rotateScale}) Widget

Available on Signal<bool>, provided by the BooleanMorphExtensions extension

Create a play/pause icon morph.
pulsing({required Widget to(BuildContext context, T value), bool when(T value)?, Duration duration = const Duration(milliseconds: 1000)}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a pulsing slot for attention.
removeListener(AtomListener listener) → void
Removes a previously added listener.
inherited
reset() → void
Resets the atom to its initial value.
inherited
select<R>(R selector(S value)) NeuronAtom<R>
Creates a new atom that selects a part of this atom's value.
inherited
select<S>(S selector(T value)) SignalSelector<T, S>

Available on Signal<T>, provided by the SignalHelpers extension

Create a selector for granular rebuilds.
slot(Widget builder(BuildContext context, T value)) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a basic Slot widget from this signal.
smooth({required Widget to(BuildContext context, double animatedValue)}) Widget

Available on Signal<T>, provided by the NumericSignalSlotExtensions extension

Create a smooth spring animation.
snapshot() → T

Available on Signal<T>, provided by the SignalExtensions extension

Get current snapshot.
spring({required Widget to(BuildContext context, double animatedValue), SpringConfig config = const SpringConfig(), double? clampMin, double? clampMax}) Widget

Available on Signal<T>, provided by the NumericSignalSlotExtensions extension

Create a SpringSlot with physics-based animation.
sub(num amount) → void

Available on Signal<T>, provided by the SignalExtensions extension

Subtract amount from numeric signal and emit. Alias for decrement.
subscribe(VoidCallback listener) VoidCallback
Adds a listener and returns a callback that cancels the subscription when called.
inherited
tappable({required Widget to(BuildContext context, T value), VoidCallback? onTap, VoidCallback? onDoubleTap, VoidCallback? onLongPress, double pressedScale = 0.95}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a gesture-animated slot.
throttle(Duration duration) ThrottledSignal<T>

Available on Signal<T>, provided by the SignalHelpers extension

Create a throttled version of this signal.
throttled({required Widget to(BuildContext context, T value), Duration duration = const Duration(milliseconds: 100)}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a throttled slot.
toggle() → void

Available on Signal<T>, provided by the SignalExtensions extension

Toggle boolean signal.
toString() String
A string representation of this object.
inherited
transition({required Widget to(BuildContext context, T value), SlotTransition type = SlotTransition.fade, Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.easeInOut}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a TransitionSlot with specified transition type.
undoable({int maxHistory = 50}) UndoableSignal<T>

Available on Signal<T>, provided by the SignalHelpers extension

Create an undoable version of this signal.
visibilityMorph({double size = 24, Color? color, IconMorphStyle style = IconMorphStyle.crossFade}) Widget

Available on Signal<bool>, provided by the BooleanMorphExtensions extension

Create a visibility toggle icon morph.
when({required bool condition(T value), required Widget to(BuildContext context, T value), Widget orElse(BuildContext context)?}) Widget

Available on Signal<T>, provided by the SignalSlotExtensions extension

Create a conditional slot with when/orElse.

Operators

operator ==(Object other) bool
The equality operator.
inherited