cubit 0.0.1 cubit: ^0.0.1 copied to clipboard
An experimental Dart library which expose a cubit. A cubit is a reimagined bloc (from package:bloc) which removes events and relies on methods to emit new states instead.
WARNING: This is highly experimental
An experimental Dart library which exposes a cubit
. A cubit is a reimagined bloc (from package:bloc) which removes events and relies on methods to emit new states instead.
Creating a Cubit #
class CounterCubit extends Cubit<int> {
@override
int get initialState => 0;
Future<void> increment() => emit(state + 1);
Future<void> decrement() => emit(state - 1);
}
Consuming a Cubit #
void main() async {
final counterCubit = CounterCubit()..listen(print);
await counterCubit.increment();
await counterCubit.decrement();
}
The above code outputs:
0
1
0