ToggleSignal class

============================================================================ TOGGLE SIGNAL (BOOLEAN HELPER)

Signal specialized for boolean values with convenience methods.

ToggleSignal makes working with boolean states easier.

Example:

class MenuController extends NeuronController {
  late final isOpen = ToggleSignal(false).bind(this);

  void openMenu() => isOpen.enable();
  void closeMenu() => isOpen.disable();
  void toggleMenu() => isOpen.toggle();
}
Inheritance
Available extensions

Constructors

ToggleSignal(bool initial, {String? debugLabel})

Properties

debugLabel String?
Debug label for identification in DevTools.
finalinherited
equals bool Function(bool a, bool b)?
Custom equality function to determine if value has changed.
finalinherited
guard bool Function(bool current, bool 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 bool
The initial value of the atom.
no setterinherited
isDisabled bool
Whether currently disabled.
no setter
isDisposed bool
Whether this atom has been disposed.
no setterinherited
isEnabled bool
Whether currently enabled.
no setter
onCancel VoidCallback?
Callback invoked when the last listener unsubscribes.
finalinherited
onListen VoidCallback?
Callback invoked when the first listener subscribes.
finalinherited
previousValue bool?
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<bool>
A broadcast stream of value changes.
no setterinherited
val bool
Short alias for the current value.
no setterinherited
value bool
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
disable() → void
Set to false.
dispose() → void
Disposes the atom, removing all listeners.
inherited
emit(bool val) → void
Assigns a new value and notifies listeners if the value changed.
inherited
enable() → void
Set to true.
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.

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

Create a menu/close icon morph (hamburger menu).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Manually notifies all listeners.
inherited
off() → void
Alias for disable().
on() → void
Alias for enable().
onActive() → void
Called when the first listener is added.
inherited
onInactive() → void
Called when the last listener is removed.
inherited
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.
removeListener(VoidCallback listener) → void
Removes a previously added listener.
inherited
reset() → void
Resets the atom to its initial value.
inherited
select<R>(R selector(bool value)) NeuronAtom<R>
Creates a new atom that selects a part of this atom's value.
inherited
subscribe(VoidCallback listener) VoidCallback
Adds a listener and returns a callback that cancels the subscription when called.
inherited
toggle() → void
Toggle the boolean value.
toString() String
A string representation of this object.
inherited
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.

Operators

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