Skip to main content

avoid-returning-value-from-cubit-methods

Warns when a Cubit method returns a value.

Example

❌ Bad:

class CounterCubit extends Cubit<int> {
CounterCubit() : super(0);

// LINT: Avoid 'Cubit' methods that return a value.
// Try listening for a state change instead.
String getAsString() => state.toString();
}

✅ Good:

class CounterCubit extends Cubit<int> {
CounterCubit() : super(0);

// Listen to a Cubit state change instead
}