lazySignal#
Kind:
function |
Package: package:signals_flutter
Function: lazySignal#
FlutterSignal<T> lazySignal({core.SignalOptions<T>? options, @Deprecated('Use options: SignalOptions(name: ...) instead') String? debugLabel, @Deprecated('Use options: SignalOptions(autoDispose: ...) instead') bool? autoDispose, bool runCallbackOnListen = false})
Creates a lazy, mutable FlutterSignal of type T whose value can be assigned later.
Reading a lazy signal's value before it has been initialized will throw a runtime error.
Example#
final database = lazySignal<DatabaseConnection>();
// Initialize later (e.g. in initState or async initialization):
database.value = await connectToDatabase();
// Now it is safe to read:
print('Connected to: ${database.value.host}');
Function: lazySignal#
Signal<T> lazySignal({SignalOptions<T>? options, @Deprecated('Use options: SignalOptions(autoDispose: ...) instead') bool? autoDispose, @Deprecated('Use options: SignalOptions(name: ...) instead') String? debugLabel})
Lazy signal that can be created with type T that the value will be assigned later.
final db = lazySignal<DatabaseConnection>();
...
db.value = DatabaseConnect(...);
References#
The lazySignal type is referenced and used in the following pages:
- Signal (signals_flutter/core)
- Signal (signals_core/core)
- Lazy Signal (signals/extensions)