avoid-bloc-public-fields
Warns when a Bloc
or Cubit
has public fields.
It's recommended to keep the state or your Blocs private and only update it in event handlers.
Example
❌ Bad:
class CounterBloc extends Bloc<CounterEvent, int> {
CounterBloc() : super(0);
// LINT: Avoid declaring public fields for 'Blocs'. Try making them private instead.
int value = 1;
}
✅ Good:
class CounterBloc extends Bloc<CounterEvent, int> {
CounterBloc() : super(0);
int _value = 1;
}