Atom<T> constructor
Atom<T> ({
- required String key,
- required T defaultValue,
- List<
AtomEffect< ? effects,T> >
Creates an Atom, which represents a piece of writeable state
- Define a unique
key
in order to identify the relative atom - Use
defaultValue
in order to set the initial value of the Atom - Use
effects
in order to add custom actions to Atom
It's possibile to create an array of effects to give different actions to Atom:
final fooAtom = Atom(
key: 'foo_atom_key',
defaultValue: initialValue,
effects: [
(onItemSet, setItemData) {
// First Effect
},
(onItemSet, setItemData) {
// Second Effect
},
],
);
See also:
Implementation
Atom({
required String key,
required this.defaultValue,
this.effects,
}) : super(key: key);