MiddlewareSignal<T> class

Signal with middleware support.

MiddlewareSignal allows you to intercept and transform values before they're emitted.

Basic Usage

final age = MiddlewareSignal<int>(
  0,
  middlewares: [
    // Ensure age is between 0 and 120
    ClampMiddleware(min: 0, max: 120),

    // Log changes
    LoggingMiddleware(label: 'Age'),
  ],
);

age.value = 150; // Clamped to 120, logged
Inheritance
Available extensions

Constructors

MiddlewareSignal(T initial, {required List<SignalMiddleware<T>> middlewares, String? debugLabel, bool equals(T a, T b)?, T guard(T current, T next)?, VoidCallback? onListen, VoidCallback? onCancel})

Properties

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

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) → void
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.
inherited
distinct() DistinctSignal<T>

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

Create a distinct version of this signal.
emit(T val) → void
Assigns a new value and notifies listeners if the value changed.
override
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
Called when the first listener is added.
inherited
onInactive() → void
Called when the last listener is removed.
inherited
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(VoidCallback listener) → void
Removes a previously added listener.
inherited
reset() → void
Resets the atom to its initial value.
inherited
select<R>(R selector(T 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