Skip to content

use_cubit_suffix

v0.1.0 Warning Fix Class Naming

This rule flags classes that extend Cubit but don’t include the Cubit suffix in their name. Consistent naming makes it immediately clear which classes are Cubits when scanning through code or reading imports.

When a class extends Cubit but is named something generic like Counter or AuthManager, it becomes unclear whether it’s a Cubit, a plain class, or some other state holder. The Cubit suffix is a standard convention in the Bloc ecosystem that communicates intent instantly.

See also: Bloc naming conventions

import 'package:bloc/bloc.dart';
// Missing 'Cubit' suffix
class Counter extends Cubit<int> {
Counter() : super(0);
void increment() => emit(state + 1);
}
import 'package:bloc/bloc.dart';
class CounterCubit extends Cubit<int> {
CounterCubit() : super(0);
void increment() => emit(state + 1);
}

To disable this rule:

plugins:
many_lints:
diagnostics:
use_cubit_suffix: false