writeable<T> function
Function that creates a store which has values that can be set from
'outside' components. It gets created as an record with additional set
and
update
methods.
set
: is a method that takes one argument which is the value to be set. The store value gets set to the value of the argument if the store value is not already equal to it.update
: is a method that takes one argument which is a callback. The callback takes the existing store value as its argument and returns the new value to be set to the store.
final count = writeable(0);
count.subscribe((value) => print(value));
count.set(1); // Print 1
count.update((value) => value + 1); // Print 2
Implementation
Writeable<T> writeable<T>(T value, [StartStopNotifier<T>? start]) =>
_Writeable(value, start);