CounterSignal class

============================================================================ COUNTER SIGNAL (NUMERIC HELPER)

Signal specialized for numeric values with increment/decrement.

CounterSignal provides convenient methods for numeric operations.

Example:

class CartController extends NeuronController {
  late final itemCount = CounterSignal(0, min: 0, max: 99).bind(this);

  void addItem() => itemCount.increment();
  void removeItem() => itemCount.decrement();
}
Inheritance
Available extensions

Constructors

CounterSignal(num initial, {num? min, num? max, num step = 1, String? debugLabel})

Properties

debugLabel String?
Debug label for identification in DevTools.
finalinherited
equals bool Function(num a, num b)?
Custom equality function to determine if value has changed.
finalinherited
guard num Function(num current, num 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 num
The initial value of the atom.
no setterinherited
isAtMax bool
Whether at maximum.
no setter
isAtMin bool
Whether at minimum.
no setter
isDisposed bool
Whether this atom has been disposed.
no setterinherited
max num?
final
min num?
final
onCancel VoidCallback?
Callback invoked when the last listener unsubscribes.
finalinherited
onListen VoidCallback?
Callback invoked when the first listener subscribes.
finalinherited
previousValue num?
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
step num
final
stream Stream<num>
A broadcast stream of value changes.
no setterinherited
val num
Short alias for the current value.
no setterinherited
value num
Override value getter to support dependency tracking for Computed.
getter/setter pairinherited

Methods

addListener(VoidCallback listener) → void
Adds a listener to be called when the value changes.
inherited
bouncy({required Widget to(BuildContext context, double animatedValue)}) Widget

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

Create a bouncy spring animation.
decrement([num? customStep]) → void
Decrement by step.
dispose() → void
Disposes the atom, removing all listeners.
inherited
emit(num val) → void
Assigns a new value and notifies listeners if the value changed.
inherited
increment([num? customStep]) → void
Increment by step.
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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Manually notifies all listeners.
inherited
onActive() → void
Called when the first listener is added.
inherited
onInactive() → void
Called when the last listener is removed.
inherited
removeListener(VoidCallback listener) → void
Removes a previously added listener.
inherited
reset([num? value]) → void
Reset to initial value or custom value.
override
select<R>(R selector(num value)) NeuronAtom<R>
Creates a new atom that selects a part of this atom's value.
inherited
setMax() → void
Set to maximum value.
setMin() → void
Set to minimum value.
smooth({required Widget to(BuildContext context, double animatedValue)}) Widget

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

Create a smooth spring animation.
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.
subscribe(VoidCallback listener) VoidCallback
Adds a listener and returns a callback that cancels the subscription when called.
inherited
toString() String
A string representation of this object.
inherited

Operators

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