cubit 0.0.8 cubit: ^0.0.8 copied to clipboard
A cubit is a subset of package:bloc which has no notion of events and relies on methods to emit new states.
WARNING: This is highly experimental
A cubit
is a subset of bloc which has no notion of events and relies on methods to emit
new states.
Every cubit
requires an initial state which will be the state of the cubit
before emit
has been called.
The current state of a cubit
can be accessed via the state
getter.
Creating a Cubit #
class CounterCubit extends Cubit<int> {
CounterCubit() : super(0);
void increment() => emit(state + 1);
}
Consuming a Cubit #
void main() async {
final cubit = CounterCubit()..increment();
await cubit.close();
}
Dart Versions #
- Dart 2: >= 2.7.0