DistinctSignal<T> class
Distinct signal - filters out duplicate consecutive values.
DistinctSignal only emits when the value actually changes.
Note: Standard Signal already does this if equals is not null.
This class is useful when wrapping another signal that might emit duplicates.
Basic Usage
final status = Signal<String>('idle');
final distinctStatus = DistinctSignal(status);
distinctStatus.addListener(() {
print('Status changed: ${distinctStatus.value}');
});
- Inheritance
-
- Object
- NeuronAtom<
T> - Signal<
T> - DistinctSignal
- Available extensions
Constructors
-
DistinctSignal(Signal<
T> source, {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
- 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
-
source
→ Signal<
T> -
final
-
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<
AddT> , provided by the SignalExtensions extensionamountto 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<
Create an AnimatedSlot with elegant syntax.T> , provided by the SignalSlotExtensions extension -
bind(
NeuronController parent) → T -
Available on T, provided by the SignalBinding extension
Registers this notifier to be disposed withparent. -
bouncy(
{required Widget to(BuildContext context, double animatedValue)}) → Widget -
Available on Signal<
Create a bouncy spring animation.T> , provided by the NumericSignalSlotExtensions extension -
debounce(
Duration duration) → DebouncedSignal< T> -
Available on Signal<
Create a debounced version of this signal.T> , provided by the SignalHelpers extension -
debounced(
{required Widget to(BuildContext context, T value), Duration duration = const Duration(milliseconds: 300)}) → Widget -
Available on Signal<
Create a debounced slot.T> , provided by the SignalSlotExtensions extension -
dec(
[num by = 1]) → void -
Available on Signal<
Short alias for decrement. Decrements numeric signal byT> , provided by the SignalExtensions extensionby(default 1). -
decrement(
[num by = 1]) → void -
Available on Signal<
Decrement numeric signal.T> , provided by the SignalExtensions extension -
dispose(
) → void -
Disposes the atom, removing all listeners.
override
-
distinct(
) → DistinctSignal< T> -
Available on Signal<
Create a distinct version of this signal.T> , provided by the SignalHelpers extension -
emit(
T 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<
Create an expand/collapse icon morph.bool> , provided by the BooleanMorphExtensions extension -
favoriteMorph(
{double size = 24, Color? activeColor, Color? inactiveColor, IconMorphStyle style = IconMorphStyle.scale}) → Widget -
Available on Signal<
Create a favorite toggle icon morph.bool> , provided by the BooleanMorphExtensions extension -
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<
Create a FormSlot for this signal.T> , provided by the FormSignalExtensions extension -
inc(
[num by = 1]) → void -
Available on Signal<
Short alias for increment. Increments numeric signal byT> , provided by the SignalExtensions extensionby(default 1). -
increment(
[num by = 1]) → void -
Available on Signal<
Increment numeric signal.T> , provided by the SignalExtensions extension -
interpolated(
{required Widget to(BuildContext context, double animatedValue), Duration duration = const Duration(milliseconds: 500), Curve curve = Curves.easeOutCubic}) → Widget -
Available on Signal<
Create an AnimatedValueSlot that interpolates the numeric value.T> , provided by the NumericSignalSlotExtensions extension -
lazy(
{required Widget to(BuildContext context, T value), Widget placeholder(BuildContext context)?}) → Widget -
Available on Signal<
Create a lazy slot that defers building.T> , provided by the SignalSlotExtensions extension -
memoized(
{required Widget to(BuildContext context, T value), bool equals(T a, T b)?}) → Widget -
Available on Signal<
Create a memoized slot with custom equality.T> , provided by the SignalSlotExtensions extension -
Available on Signal<
Create a menu/close icon morph (hamburger menu).bool> , provided by the BooleanMorphExtensions extension -
morph(
{required MorphableWidget morphBuilder(BuildContext context, T value), MorphConfig config = const MorphConfig(), VoidCallback? onMorphStart, VoidCallback? onMorphComplete}) → Widget -
Available on Signal<
Create a MorphSlot for this signal.T> , provided by the MorphSignalExtensions extension -
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<
Create an IconMorphSlot for this signal.T> , provided by the MorphSignalExtensions extension -
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<
Create a persistent version of this signal.T> , provided by the SignalHelpers extension -
pipeTo(
Signal< T> target) → StreamSubscription<T> -
Available on Signal<
Pipe values to another signal.T> , provided by the SignalExtensions extension -
playPauseMorph(
{double size = 24, Color? color, IconMorphStyle style = IconMorphStyle.rotateScale}) → Widget -
Available on Signal<
Create a play/pause icon morph.bool> , provided by the BooleanMorphExtensions extension -
pulsing(
{required Widget to(BuildContext context, T value), bool when(T value)?, Duration duration = const Duration(milliseconds: 1000)}) → Widget -
Available on Signal<
Create a pulsing slot for attention.T> , provided by the SignalSlotExtensions extension -
removeListener(
AtomListener 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<
Create a selector for granular rebuilds.T> , provided by the SignalHelpers extension -
slot(
Widget builder(BuildContext context, T value)) → Widget -
Available on Signal<
Create a basic Slot widget from this signal.T> , provided by the SignalSlotExtensions extension -
smooth(
{required Widget to(BuildContext context, double animatedValue)}) → Widget -
Available on Signal<
Create a smooth spring animation.T> , provided by the NumericSignalSlotExtensions extension -
snapshot(
) → T -
Available on Signal<
Get current snapshot.T> , provided by the SignalExtensions extension -
spring(
{required Widget to(BuildContext context, double animatedValue), SpringConfig config = const SpringConfig(), double? clampMin, double? clampMax}) → Widget -
Available on Signal<
Create a SpringSlot with physics-based animation.T> , provided by the NumericSignalSlotExtensions extension -
sub(
num amount) → void -
Available on Signal<
SubtractT> , provided by the SignalExtensions extensionamountfrom 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<
Create a gesture-animated slot.T> , provided by the SignalSlotExtensions extension -
throttle(
Duration duration) → ThrottledSignal< T> -
Available on Signal<
Create a throttled version of this signal.T> , provided by the SignalHelpers extension -
throttled(
{required Widget to(BuildContext context, T value), Duration duration = const Duration(milliseconds: 100)}) → Widget -
Available on Signal<
Create a throttled slot.T> , provided by the SignalSlotExtensions extension -
toggle(
) → void -
Available on Signal<
Toggle boolean signal.T> , provided by the SignalExtensions extension -
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<
Create a TransitionSlot with specified transition type.T> , provided by the SignalSlotExtensions extension -
undoable(
{int maxHistory = 50}) → UndoableSignal< T> -
Available on Signal<
Create an undoable version of this signal.T> , provided by the SignalHelpers extension -
visibilityMorph(
{double size = 24, Color? color, IconMorphStyle style = IconMorphStyle.crossFade}) → Widget -
Available on Signal<
Create a visibility toggle icon morph.bool> , provided by the BooleanMorphExtensions extension -
when(
{required bool condition(T value), required Widget to(BuildContext context, T value), Widget orElse(BuildContext context)?}) → Widget -
Available on Signal<
Create a conditional slot with when/orElse.T> , provided by the SignalSlotExtensions extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited