### Example Usage of derivedFuture Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup/derivedFuture An example demonstrating how to use the derivedFuture method to create a beacon that fetches data asynchronously and updates the UI based on the result. ```dart final counter = Beacon.writable(0); // The future will be recomputed whenever the counter changes final derivedFutureCounter = Beacon.derivedFuture(() async { final count = counter.value; await Future.delayed(Duration(seconds: count)); return '$count second has passed.'; }); class FutureCounter extends StatelessWidget { const FutureCounter({super.key}); @override Widget build(BuildContext context) { return switch (derivedFutureCounter.watch(context)) { AsyncData(value: final v) => Text(v), AsyncError(error: final e) => Text('$e'), AsyncLoading() => const CircularProgressIndicator(), }; } } ``` -------------------------------- ### FutureBeacon start method Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/FutureBeacon/start Starts listening to the internal stream if manualStart was set to true. Calling this method more than once has no effect. ```dart void start() => _start(); ``` -------------------------------- ### Install Linting Dependencies Source: https://pub.dev/documentation/state_beacon/latest/index Installs the custom_lint and state_beacon_lint packages for enhanced linting rules specific to the state_beacon package. ```dart dart pub add custom_lint state_beacon_lint --dev ``` -------------------------------- ### Example Usage of bufferedTime Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup/bufferedTime Demonstrates how to create and use a bufferedTime beacon. Values are collected over a 5-second duration, and then printed to the console as a list. ```dart var timeBeacon = Beacon.bufferedTime(duration: Duration(seconds: 5)); timeBeacon.subscribe((values) { print(values); }); timeBeacon.value = 1; timeBeacon.value = 2; // After 5 seconds, it will output [1, 2] ``` -------------------------------- ### Writable Beacon Example Source: https://pub.dev/documentation/state_beacon/latest/index Demonstrates the core functionality of a WritableBeacon, showing how to set and retrieve its value. It highlights the composability aspect compared to simple ValueNotifiers. ```dart final counter = Beacon.writable(0); counter.value = 10; print(counter.value); // 10 ``` -------------------------------- ### Example Usage of toFuture Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/FutureBeacon/toFuture Demonstrates how to use the `toFuture` method to await Futures derived from other Beacons, combining their results. ```dart var count = Beacon.writable(0); var firstName = Beacon.future(() async => 'Sally ${count.value}'); var lastName = Beacon.future(() async => 'Smith ${count.value}'); var fullName = Beacon.future(() async { // no need for a manual switch expression final fnameFuture = firstName.toFuture(); final lnameFuture = lastName.toFuture(); final fname = await fnameFuture; final lname = await lnameFuture; return '$fname $lname'; }); ``` -------------------------------- ### StreamBeacon start method Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/StreamBeacon/start Starts listening to the internal stream if `manualStart` was set to true. Calling this method more than once has no effect. ```dart void start() => _start(); ``` -------------------------------- ### Dependency Injection with lite_ref Source: https://pub.dev/documentation/state_beacon/latest/index Provides an example of using lite_ref for dependency injection, managing beacon disposal when widgets unmount. It shows how to watch beacons within widgets. ```Dart class CountController extends BeaconController { late final count = B.writable(0); late final doubledCount = B.derived(() => count.value * 2); } final countControllerRef = Ref.scoped((ctx) => CountController()); class CounterText extends StatelessWidget { const CounterText({super.key}); @override Widget build(BuildContext context) { // watch the count beacon and return its value final count = countControllerRef.select(context, (c) => c.count); return Text('$count'); } } ``` -------------------------------- ### Lazy Writable Beacon Example Source: https://pub.dev/documentation/state_beacon/latest/index Demonstrates the creation and usage of a lazy writable beacon. Accessing an uninitialized lazy beacon before assignment throws an UninitializeLazyReadException. ```dart final counter = Beacon.lazyWritable(); print(counter.value); // throws UninitializeLazyReadException() counter.value = 10; print(counter.value); // 10 ``` -------------------------------- ### BeaconGroup Usage Example Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup-class Demonstrates how to create a BeaconGroup, add writable beacons and effects to it, and then reset or dispose of all managed beacons and effects. ```dart final myGroup = BeaconGroup(); final name = myGroup.writable('Bob'); final age = myGroup.writable(20); myGroup.effect(() { print(name.value); }); age.value = 21; name.value = 'Alice'; myGroup.resetAll(); print(name.value); // Bob print(age.value); // 20 myGroup.disposeAll(); print(name.isDisposed); // true print(age.isDisposed); // true ``` -------------------------------- ### FutureBeacon Properties and Methods Source: https://pub.dev/documentation/state_beacon/latest/index Lists the available properties and methods for FutureBeacons, including state checks (`isIdle`, `isLoading`, `isData`, `isError`), accessing data (`lastData`, `unwrapValue`, `unwrapValueOrNull`), and control methods (`start`, `reset`, `toFuture`, `overrideWith`). ```APIDOC Properties: * `isIdle`: bool * `isLoading`: bool * `isIdleOrLoading`: bool * `isData`: bool * `isError`: bool * `lastData`: T? (Returns the last successful data value or null) Methods: * `start()`: Starts the future if it's in the `idle` state. * `reset()`: Resets the beacon by running the callback again. Enters the `loading` state. * `unwrapValue()`: Returns the value if the beacon is in the `data` state. Throws an error otherwise. * `unwrapValueOrNull()`: Returns the value if in `data` state, otherwise null. * `toFuture()`: Returns a future that completes with the value when the beacon is in the `data` state. Throws an error otherwise. * `overrideWith(Future Function() callback)`: Replaces the current callback and resets the beacon. ``` -------------------------------- ### Install state_beacon Package Source: https://pub.dev/documentation/state_beacon/latest/index Adds the state_beacon package as a dependency to your Dart or Flutter project using the Dart package manager. ```dart dart pub add state_beacon ``` -------------------------------- ### state_beacon Library Overview Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/MapBeacon-class Provides a detailed breakdown of the state_beacon library's structure, including its classes, mixins, constants, typedefs, exceptions, and extensions. It also outlines the constructors, properties, methods, and operators available for state management. ```APIDOC state_beacon Library Structure: Classes: AsyncData, AsyncError, AsyncIdle, AsyncLoading, AsyncSingletonRef, AsyncTransientRef, AsyncValue, BeaconController, BeaconFamily, BeaconGroup, BeaconObserver, BeaconScheduler, BufferedCountBeacon, BufferedTimeBeacon, DebouncedBeacon, Disposable, FilteredBeacon, FutureBeacon, IScopedRef, ListBeacon, LiteRefScope, LoggingObserver, MapBeacon, PeriodicBeacon, Producer, RawStreamBeacon, ReadableBeacon, Ref, ScopedFamilyRef, ScopedObject, ScopedRef, SetBeacon, SingletonRef, StreamBeacon, TextEditingBeacon, ThrottledBeacon, TimestampBeacon, TransientRef, UndoRedoBeacon, WritableBeacon Mixins: BeaconControllerMixin Constants: Beacon Typedefs: AsyncFactory, BaseBeacon, BeaconSelector, BeaconSelector2, BeaconSelector3, CtxCreateFn, CtxFamilyCreateFn, DisposeFn, ObserverCallback Exceptions: UninitializeLazyReadException, WrapTargetWrongTypeException Extensions: BoolUtils, IntUtils, ListUtils, LiteRefBeaconControllerExt, LiteRefBeaconExt, ReadableAsyncBeaconUtils, ReadableBeaconFlutterUtils, ReadableBeaconUtils, ReadableBeaconWrapUtils, StreamUtils, WidgetUtils, WritableAsyncBeacon, WritableBeaconFlutterUtils, WritableBeaconUtils, WritableWrap Constructors: new Properties: $$widgetSubscribers$$, hashCode, initialValue, isDisposed, isEmpty, listenersCount, name, previousValue, runtimeType, stream, value Methods: addAll, call, clear, clearWrapped, dispose, noSuchMethod, onDispose, peek, putIfAbsent, remove, removeWhere, reset, set, subscribe, toStream, toString, update, updateAll Operators: operator ==, operator [], operator []= ``` -------------------------------- ### Dart ListBeacon removeRange Method Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/ListBeacon/removeRange Removes a range of elements from the list. The elements with positions greater than or equal to `start` and less than `end` are removed. The list's length is reduced by `end - start`. The provided range must be valid (0 ≤ start ≤ end ≤ length). The list must be growable. ```dart void removeRange( int start, int end ) ``` ```dart final numbers = [1, 2, 3, 4, 5]; numbers.removeRange(1, 4); print(numbers); // [1, 5] ``` ```dart void removeRange(int start, int end) { _value.removeRange(start, end); _setValue(_value, force: true); } ``` -------------------------------- ### BeaconGroup effect method example Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup/effect Example demonstrating the usage of the effect method to react to changes in a beacon's value and print messages accordingly. ```dart final age = Beacon.writable(15); Beacon.effect(() { if (age.value >= 18) { print("You can vote!"); } else { print("You can't vote yet"); } }); // Outputs: "You can't vote yet" age.value = 20; // Outputs: "You can vote!" ``` -------------------------------- ### PeriodicBeacon Usage Example Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup/periodic An example demonstrating how to use the `periodic` method to create a beacon that emits incrementing integers every second and then buffers the first five emitted values. ```dart final myBeacon = Beacon.periodic(Duration(seconds: 1), (i) => i + 1); final nextFive = await myBeacon.buffer(5).next(); expect(nextFive, [1, 2, 3, 4, 5]); ``` -------------------------------- ### BeaconController Class Methods and Properties Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconController/BeaconController Provides an overview of the BeaconController class, including its constructors, properties (like hashCode, runtimeType), methods (dispose, noSuchMethod, toString), and operators (operator ==). ```APIDOC BeaconController class: Constructors: new: Creates a new BeaconController instance. Properties: hashCode: The hash code for this object. runtimeType: A singleton subclass of Type that represents the runtime type of the object. Methods: dispose(): Disposes of the resources associated with the controller. noSuchMethod(Invocation invocation): Invoked when a non-existent method or property is accessed. toString(): A string representation of this object, called by toString(minimumCharacters: 0). Operators: operator ==(Object other): The equality operator. ``` -------------------------------- ### AsyncIdle Class Properties and Methods Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/AsyncIdle/AsyncIdle Provides an overview of the properties and methods available for the AsyncIdle class, including checks for data, error, or loading states, accessing the last data, and utility methods like toString and unwrap. ```APIDOC AsyncIdle class: Properties: - hashCode: The hash code for this object. - isData: Returns true if the state contains data. - isError: Returns true if the state contains an error. - isIdle: Returns true if the state is idle (no data, no error, not loading). - isIdleOrLoading: Returns true if the state is idle or loading. - isLoading: Returns true if the state is currently loading. - lastData: The last successfully received data, or null if none. - runtimeType: A representation of the runtime type of the object. - valueOrNull: Returns the value if it is data, otherwise null. Methods: - noSuchMethod(Invocation invocation): Invoked when a non-existent method or property is accessed. - setLastData(T? data): Sets the last received data. - toString(): Returns a string representation of the object. - unwrap(): Returns the value if it is data, otherwise throws an error. - unwrapOrNull(): Returns the value if it is data, otherwise null. Operators: - operator ==(Object other): Equality comparison. ``` -------------------------------- ### Dart ListBeacon replaceRange Method Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/ListBeacon/replaceRange Replaces a range of elements in a ListBeacon with elements from another iterable. It removes elements from start to end and inserts the new elements at the start position. This operation is similar to removeRange followed by insertAll but may be more efficient. The list must be growable. ```Dart void replaceRange( int start, int end, Iterable replacements ) // Example usage: final numbers = [1, 2, 3, 4, 5]; final replacements = [6, 7]; numbers.replaceRange(1, 4, replacements); print(numbers); // [1, 6, 7, 5] ``` ```Dart void replaceRange(int start, int end, Iterable replacements) { _value.replaceRange(start, end, replacements); _setValue(_value, force: true); } ``` -------------------------------- ### Writable Beacon Creation Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup-class Creates a WritableBeacon that allows both reading and writing of its value. It can be initialized with a starting value. ```Dart writable(T initialValue, {String? name}) → WritableBeacon ``` -------------------------------- ### Example Usage of updateAll Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/MapBeacon/updateAll Demonstrates how to use the updateAll method to convert all string values in a MapBeacon to uppercase. ```dart final terrestrial = {1: 'Mercury', 2: 'Venus', 3: 'Earth'}; terrestrial.updateAll((key, value) => value.toUpperCase()); print(terrestrial); // {1: MERCURY, 2: VENUS, 3: EARTH} ``` -------------------------------- ### Producer Class API Documentation Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/Producer/name Comprehensive API documentation for the Producer class in the state_beacon package. Includes constructors, properties, methods, extensions, and operators. ```APIDOC Producer Properties: - $$widgetSubscribers$$: Internal property related to widget subscriptions. - hashCode: Computes the hash code for the producer. - initialValue: The initial value of the producer. - isDisposed: Returns true if the producer has been disposed. - isEmpty: Returns true if the producer has no listeners. - listenersCount: The number of active listeners. - name: The name of the beacon for debugging. - previousValue: The previous value of the producer. - runtimeType: The runtime type of the producer. - value: The current value of the producer. Methods: - call(): Invokes the producer, typically to update its value. - dispose(): Disposes of the producer and cleans up resources. - noSuchMethod(Invocation invocation): Handles calls to non-existent methods. Extensions: - observe(Function(T) onData): Subscribes to the producer and calls the callback when the value changes. - watch(Function(T) onData): Similar to observe, likely for reactive programming patterns. Operators: - operator ==(Object other): Compares the producer with another object for equality. ``` -------------------------------- ### Ref Class Static Methods Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/Ref/scoped Lists the available static methods on the `Ref` class in the state_beacon package, including methods for creating different types of references like `asyncSingleton`, `asyncTransient`, `scoped`, `scopedFamily`, `singleton`, and `transient`. ```APIDOC Ref class static methods: - asyncSingleton - asyncTransient - scoped - scopedFamily - singleton - transient ``` -------------------------------- ### Ref Class Constructor Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/Ref/Ref The documentation provides details on the 'new' constructor for the Ref class within the state_beacon package. It outlines the class structure, including constructors, properties, methods, and operators. ```dart Ref() // Constructors // new // Properties // hashCode // runtimeType // Methods // noSuchMethod // toString // Operators // operator == // Static methods // asyncSingleton // asyncTransient // scoped // scopedFamily // singleton // transient ``` -------------------------------- ### Example Usage of filter method Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/ReadableBeaconWrapUtils/filter Demonstrates how to use the filter method to create a beacon that only accepts values greater than 10. ```dart final count = Beacon.writable(10); final filteredCount = count.filter((prev, next) => next > 10); filteredCount.value = 20; // equivalent to count.set(20, force: true); expect(count.value, equals(20)); expect(filteredCount.value, equals(20)); ``` -------------------------------- ### state_beacon Constructors, Properties, and Methods Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/ListBeacon-class Details the constructors, properties, and methods available for classes within the state_beacon library, such as 'new', 'value', 'dispose', and 'subscribe'. ```dart Constructors: new Properties: $$widgetSubscribers$$ first hashCode initialValue isDisposed isEmpty last length listenersCount name previousValue runtimeType stream value Methods: add addAll call clear clearWrapped dispose fillRange insert insertAll mapInPlace noSuchMethod onDispose peek remove removeAt removeLast removeRange removeWhere replaceRange reset retainWhere set setAll setRange shuffle sort subscribe toStream toString Operators: operator == operator []= ``` -------------------------------- ### Beacon State Access (Last Data) Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/UndoRedoBeacon-class Details the extension property to get the last successfully resolved data from an async beacon. ```dart lastData (ext) ``` -------------------------------- ### StreamBeacon Constructor Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/StreamBeacon-class Initializes a new StreamBeacon. It takes a stream computation function, and optional parameters for error handling, naming, and manual starting. ```dart StreamBeacon.new(Stream _compute(), {required bool shouldSleep, bool cancelOnError = false, String? name, bool manualStart = false}) ``` -------------------------------- ### TextEditingBeacon Constructor Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/TextEditingBeacon-class Initializes a new TextEditingBeacon, optionally with initial text and configuration. ```dart TextEditingBeacon.new({String? text, BeaconGroup? group, String? name}) ``` -------------------------------- ### FutureBeacon idle method Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/FutureBeacon/idle Sets the beacon to the AsyncIdle state. The `lastData` will be set to the current value. The beacon will have to be started manually to resume. ```dart void idle() { _setValue(AsyncIdle()..setLastData(lastData)); _cancel(); } ``` -------------------------------- ### Example Usage of overrideWith in LiteRefScope Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/ScopedRef/overrideWith Demonstrates how to use the overrideWith method within a LiteRefScope to provide mock implementations or override existing services. ```dart LiteRefScope( overrides: [ settingsServiceRef.overrideWith((ctx) => MockSettingsService()), ] child: MyApp(), ), ``` -------------------------------- ### Alternative Beacon Watching with lite_ref Source: https://pub.dev/documentation/state_beacon/latest/index Demonstrates an alternative way to watch beacons using lite_ref's of() method, which is equivalent to the select() method. ```Dart final count = countControllerRef.select(context, (c) => c.count); // is equivalent to final controller = countControllerRef.of(context); final count = controller.count.watch(context); ``` -------------------------------- ### LoggingObserver Constructor Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/LoggingObserver/LoggingObserver Initializes a new LoggingObserver. You can optionally provide lists of names to include or exclude from logging. ```dart LoggingObserver({ List? includeNames, List? excludeNames, }); ``` ```dart LoggingObserver({this.includeNames, this.excludeNames}); ``` -------------------------------- ### Watching Multiple Beacons with select2 Source: https://pub.dev/documentation/state_beacon/latest/index Shows how to use select2 to watch multiple beacons simultaneously, providing a more concise way to access related beacon states. ```Dart final (count, doubledCount) = countControllerRef.select2(context, (c) => (c.count, c.doubledCount)); // is equivalent to final controller = countControllerRef.of(context); final count = controller.count.watch(context); final doubledCount = controller.doubledCount.watch(context); ``` -------------------------------- ### Producer Class API Documentation Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/Producer/previousValue Comprehensive API documentation for the Producer class in the state_beacon Dart package. Includes constructors, properties, methods, and operators. ```APIDOC Producer class Constructors: new Producer(String? name, {T? initialValue, bool distinct = false, bool cache = true}) Initializes a new Producer. Parameters: name: Optional name for the producer. initialValue: The initial value for the producer. distinct: If true, only notify listeners when the value changes. cache: If true, cache the last value. Properties: $$widgetSubscribers$$: Internal property for widget subscribers. hashCode: The hash code for this object. initialValue: The initial value provided during construction. isDisposed: Returns true if the producer has been disposed. isEmpty: Returns true if the producer has no listeners. listenersCount: The number of active listeners. name: The name of the producer. previousValue: The previous value of the beacon. runtimeType: A representation of the runtime type of the object. value: The current value of the beacon. Methods: call(T value): Updates the producer's value and notifies listeners. dispose(): Disposes of the producer and cleans up resources. noSuchMethod(Invocation invocation): Invoked when a non-existent method or property is accessed. peek(): Returns the current value without notifying listeners. subscribe(void Function(T) listener, {bool fireImmediately = true}): Subscribes a listener to value changes. toString(): A string representation of the object. Operators: operator ==(Object other): Compares this object to another for equality. ``` -------------------------------- ### BeaconGroup batch Method Example Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup/batch Demonstrates how to use the batch method to group multiple updates to a beacon, resulting in a single notification. This is useful for optimizing performance. ```dart final age = Beacon.writable(10); var callCount = 0; age.subscribe((_) => callCount++); Beacon.batch(() { age.value = 15; age.value = 16; age.value = 20; age.value = 23; }); expect(callCount, equals(1)); // There were 4 updates, but only 1 notification ``` -------------------------------- ### BeaconGroup Class Methods Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup/lazyWritable Documentation for the BeaconGroup class, listing its constructors, properties, and methods including add, batch, debounced, derived, effect, and writable. ```APIDOC BeaconGroup class: Constructors: new Properties: beaconCount beacons hashCode runtimeType Methods: add(BeaconBase beacon) batch(void Function() updates) bufferedCount() bufferedTime(Duration duration) debounced(Duration duration) derived(T Function() getter) derivedFuture(Future Function() getter) derivedStream(Stream Function() getter) disposeAll() effect(void Function() callback) family(T Function(T value) builder) filtered(bool Function(T value) predicate) future(Future future) hashMap() hashSet() lazyDebounced(Duration duration) lazyFiltered(bool Function(T value) predicate) lazyThrottled(Duration duration) lazyTimestamped() lazyUndoRedo(int maxHistoryLength) lazyWritable({T? initialValue, String? name}) list() noSuchMethod(Invocation invocation) onCreate(void Function(BeaconBase beacon) callback) periodic(Duration duration, T Function() getter) readable(T Function() getter) resetAll() stream() streamRaw() throttled(Duration duration) timestamped() toString(): String undoRedo(int maxHistoryLength) untracked(T Function() getter) writable({T? initialValue, String? name}) Operators: operator ==(Object other) ``` -------------------------------- ### Wrap App with LiteRefScope Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/Ref/scopedFamily Shows the basic setup required to use state management features from the `state_beacon` package by wrapping the application's root widget with `LiteRefScope`. ```dart runApp( LiteRefScope( child: MyApp(), ), ); ``` -------------------------------- ### SingletonRef Constructor Implementation Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/SingletonRef/SingletonRef This snippet shows the Dart implementation of the SingletonRef constructor, which takes a create function as an argument. ```dart SingletonRef(super.create); ``` -------------------------------- ### BeaconGroup Class API Documentation Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup/lazyUndoRedo API documentation for the BeaconGroup class in the state_beacon package. Lists constructors, properties, and methods including add, batch, debounced, derived, effect, and lazyUndoRedo. ```APIDOC BeaconGroup class Constructors: - new Properties: - beaconCount: Number of beacons in the group. - beacons: A collection of beacons. - hashCode: The hash code for this object. - runtimeType: A string representation of the runtime type of the object. Methods: - add(BeaconBase beacon): Adds a beacon to the group. - batch(void Function() updates): Executes a batch of updates. - bufferedCount(): Returns the number of buffered beacons. - bufferedTime(Duration duration): Creates a beacon that buffers updates for a specified duration. - debounced(Duration duration): Creates a debounced beacon. - derived(T Function() compute, {List>? deps, String? name}): Creates a derived beacon. - derivedFuture(Future Function() compute, {List>? deps, String? name}): Creates a derived beacon that computes a future. - derivedStream(Stream Function() compute, {List>? deps, String? name}): Creates a derived beacon that computes a stream. - disposeAll(): Disposes all beacons in the group. - effect(void Function() callback, {List>? deps}): Executes a side effect. - family(T Function(String id) create, {List>? deps, String? name}): Creates a family of beacons. - filtered(T? Function(T? value) filter, {List>? deps, String? name}): Creates a filtered beacon. - future(Future future, {List>? deps, String? name}): Creates a beacon from a future. - hashMap(): Creates a beacon that holds a HashMap. - hashSet(): Creates a beacon that holds a HashSet. - lazyDebounced(Duration duration): Creates a lazily debounced beacon. - lazyFiltered(T? Function(T? value) filter): Creates a lazily filtered beacon. - lazyThrottled(Duration duration): Creates a lazily throttled beacon. - lazyTimestamped(): Creates a lazily timestamped beacon. - lazyUndoRedo({T? initialValue, int historyLimit = 10, String? name}): Creates a lazily undo/redo beacon. - lazyWritable({T? initialValue, String? name}): Creates a lazily writable beacon. - list(): Creates a beacon that holds a List. - noSuchMethod(Invocation invocation): Invoked when a non-existent method or property is accessed. - onCreate(void Function(BeaconBase beacon) callback): Registers a callback for beacon creation. - periodic(Duration duration, T Function(int count) compute): Creates a periodic beacon. - readable({T? initialValue, String? name}): Creates a readable beacon. - resetAll(): Resets all beacons in the group. - stream(Stream stream, {List>? deps, String? name}): Creates a beacon from a stream. - streamRaw(Stream stream, {List>? deps, String? name}): Creates a raw beacon from a stream. - throttled(Duration duration): Creates a throttled beacon. - timestamped(): Creates a timestamped beacon. - toString(): A string representation of this object is returned. - undoRedo({T? initialValue, int historyLimit = 10, String? name}): Creates an undo/redo beacon. - untracked(T Function() compute): Computes a value without tracking dependencies. - writable({T? initialValue, String? name}): Creates a writable beacon. Operators: - operator ==(Object other): Equality comparison. ``` -------------------------------- ### Dart ListBeacon removeAt Method Example Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/ListBeacon/removeAt Demonstrates how to use the `removeAt` method to remove an element from a `ListBeacon` by its index. The method returns the removed element and modifies the list in place. ```Dart final parts = ['head', 'shoulder', 'knees', 'toes']; final retVal = parts.removeAt(2); // knees print(parts); // [head, shoulder, toes] ``` -------------------------------- ### state_beacon Library Overview Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/SetBeacon-class This section outlines the structure and components of the state_beacon library, including its classes, mixins, constants, typedefs, exceptions, and extensions. ```APIDOC state_beacon Library Components: Classes: AsyncData, AsyncError, AsyncIdle, AsyncLoading, AsyncSingletonRef, AsyncTransientRef, AsyncValue, BeaconController, BeaconFamily, BeaconGroup, BeaconObserver, BeaconScheduler, BufferedCountBeacon, BufferedTimeBeacon, DebouncedBeacon, Disposable, FilteredBeacon, FutureBeacon, IScopedRef, ListBeacon, LiteRefScope, LoggingObserver, MapBeacon, PeriodicBeacon, Producer, RawStreamBeacon, ReadableBeacon, Ref, ScopedFamilyRef, ScopedObject, ScopedRef, SetBeacon, SingletonRef, StreamBeacon, TextEditingBeacon, ThrottledBeacon, TimestampBeacon, TransientRef, UndoRedoBeacon, WritableBeacon Mixins: BeaconControllerMixin Constants: Beacon Typedefs: AsyncFactory, BaseBeacon, BeaconSelector, BeaconSelector2, BeaconSelector3, CtxCreateFn, CtxFamilyCreateFn, DisposeFn, ObserverCallback Exceptions: UninitializeLazyReadException, WrapTargetWrongTypeException Extensions: BoolUtils, IntUtils, ListUtils, LiteRefBeaconControllerExt, LiteRefBeaconExt, ReadableAsyncBeaconUtils, ReadableBeaconFlutterUtils, ReadableBeaconUtils, ReadableBeaconWrapUtils, StreamUtils, WidgetUtils, WritableAsyncBeacon, WritableBeaconFlutterUtils, WritableBeaconUtils, WritableWrap ``` -------------------------------- ### ListBeacon.fillRange Method Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/ListBeacon/fillRange Overwrites a range of elements in the ListBeacon with a specified fill value. The range is defined by start and end indices, and the fillValue must be provided if the element type is not nullable. ```dart void fillRange(int start, int end, [E? fillValue]) { _value.fillRange(start, end, fillValue); _setValue(_value, force: true); } ``` ```dart final words = List.filled(5, 'old'); print(words); // [old, old, old, old, old] words.fillRange(1, 3, 'new'); print(words); // [old, new, new, old, old] ``` -------------------------------- ### BeaconGroup Class Methods Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/BeaconGroup/lazyThrottled Documentation for the BeaconGroup class, outlining its constructors, properties, and various methods for managing beacons. ```APIDOC BeaconGroup class Constructors: new Properties: beaconCount beacons hashCode runtimeType Methods: add batch bufferedCount bufferedTime debounced derived derivedFuture derivedStream disposeAll effect family filtered future hashMap hashSet lazyDebounced lazyFiltered lazyThrottled lazyTimestamped lazyUndoRedo lazyWritable list noSuchMethod onCreate periodic readable resetAll stream streamRaw throttled timestamped toString undoRedo untracked writable Operators: operator == ``` -------------------------------- ### isIdleOrLoading Property - AsyncLoading Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/AsyncLoading/isIdleOrLoading The isIdleOrLoading property returns true if the current state is AsyncIdle or AsyncLoading. This is a common check for determining if a data fetching operation is in progress or has not yet started. ```dart @override bool get isIdleOrLoading => true; ``` -------------------------------- ### state_beacon Classes Overview Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/ListBeacon-class Lists the various classes available in the state_beacon library, categorized into core classes, mixins, constants, typedefs, exceptions, and extensions. ```dart Classes: AsyncData AsyncError AsyncIdle AsyncLoading AsyncSingletonRef AsyncTransientRef AsyncValue BeaconController BeaconFamily BeaconGroup BeaconObserver BeaconScheduler BufferedCountBeacon BufferedTimeBeacon DebouncedBeacon Disposable FilteredBeacon FutureBeacon IScopedRef ListBeacon LiteRefScope LoggingObserver MapBeacon PeriodicBeacon Producer RawStreamBeacon ReadableBeacon Ref ScopedFamilyRef ScopedObject ScopedRef SetBeacon SingletonRef StreamBeacon TextEditingBeacon ThrottledBeacon TimestampBeacon TransientRef UndoRedoBeacon WritableBeacon Mixins: BeaconControllerMixin Constants: Beacon Typedefs: AsyncFactory BaseBeacon BeaconSelector BeaconSelector2 BeaconSelector3 CtxCreateFn CtxFamilyCreateFn DisposeFn ObserverCallback Exceptions: UninitializeLazyReadException WrapTargetWrongTypeException Extensions: BoolUtils IntUtils ListUtils LiteRefBeaconControllerExt LiteRefBeaconExt ReadableAsyncBeaconUtils ReadableBeaconFlutterUtils ReadableBeaconUtils ReadableBeaconWrapUtils StreamUtils WidgetUtils WritableAsyncBeacon WritableBeaconFlutterUtils WritableBeaconUtils WritableWrap ``` -------------------------------- ### AsyncIdle Constructor Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/AsyncIdle/AsyncIdle Initializes a new instance of the AsyncIdle class. This represents an asynchronous operation that is currently in an idle state, meaning it has not yet started or has completed without data or error. ```dart AsyncIdle() ``` -------------------------------- ### SingletonRef Class Documentation Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/SingletonRef-class Documentation for the SingletonRef class, which provides a reference that always returns a new instance. It details inheritance, constructors, properties, methods, and operators. ```APIDOC SingletonRef class A SingletonRef is a reference that always returns a new instance. Inheritance * Object * TransientRef * SingletonRef Constructors SingletonRef.new(T create()) Properties hashCode → int The hash code for this object. no setterinherited instance → T Returns the singleton instance of `T`. no setteroverride runtimeType → Type A representation of the runtime type of the object. no setterinherited Methods call() → T Equivalent to calling the instance getter. inherited freeze() → void Disables overriding. inherited noSuchMethod(Invocation invocation) → dynamic Invoked when a nonexistent method or property is accessed. inherited overrideWith(T create()) → void Sets the function used to create instances. Throws a StateError if `this` has been frozen. override toString() → String A string representation of this object. inherited Operators operator ==(Object other) → bool The equality operator. inherited ``` -------------------------------- ### AsyncSingletonRef Constructor Source: https://pub.dev/documentation/state_beacon/latest/state_beacon/AsyncSingletonRef/AsyncSingletonRef The constructor for AsyncSingletonRef takes an AsyncFactory to create the singleton instance asynchronously. ```dart AsyncSingletonRef( AsyncFactory create ) ``` ```dart AsyncSingletonRef(super.create); ``` -------------------------------- ### Debouncing Beacon Updates Source: https://pub.dev/documentation/state_beacon/latest/index Example of using the debounce method to limit the rate at which a beacon's value can be updated, often used for input fields to avoid excessive processing. ```dart final query = Beacon.writable(''); const k500ms = Duration(milliseconds: 500); final debouncedQuery = query .filter((prev, next) => next.length > 2) .debounce(duration: k500ms); ```