Skip to main content

avoid-cubits

added in: 1.2.0
Free+

Warns when a Cubit is used.

It's recommended to avoid Cubits if:

  1. You want to use only Blocs in your codebase.
  2. You want to leverage transformer and https://pub.dev/packages/bloc_concurrency.
  3. You want to avoid exceptions from Cubits getting into the main zone (Cubits use methods, whereas Blocs rely on events).
  4. 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