avoid-cubits
Warns when a Cubit
is used.
It's recommended to avoid Cubits if:
- You want to use only Blocs in your codebase.
- You want to leverage
transformer
and https://pub.dev/packages/bloc_concurrency. - You want to avoid exceptions from Cubits getting into the main zone (Cubits use methods, whereas Blocs rely on events).
- You expect the code to change and become more complex, eventually leading to the need to rewrite Cubits to Blocs.
Example
❌ Bad:
// LINT: Use of 'Cubits' is not allowed. Try creating 'Blocs' instead.
class CounterCubit extends Cubit<int> {
CounterCubit() : super(0);
}
✅ Good:
// Use Bloc instead