stateAtom<Value> function

WritableAtom<Value, Value> stateAtom<Value>(
  1. Value initialValue
)

Create a simple atom with mutable state.

final counter = stateAtom(0);

If you want to ensure the state is not automatically disposed when not in use, then call the Atom.keepAlive method.

final counter = stateAtom(0).keepAlive();

Implementation

WritableAtom<Value, Value> stateAtom<Value>(Value initialValue) =>
    StateAtom(initialValue);