severity: WARNING
Avoid public properties on Bloc
and Cubit
, prefer emit state or use private value.
❌ BAD:
class MyCubit extends Cubit<int> {
MyCubit() : super(0);
int value = 1;
}
✅ GOOD:
class MyCubit extends Cubit<int> {
MyCubit() : super(0);
void init() {
emit(1);
}
}
or
class MyCubit extends Cubit<int> {
MyCubit() : super(0);
int _value = 1;
}