Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Latest commit

 

History

History
38 lines (28 loc) · 490 Bytes

avoid_public_properties_on_bloc_and_cubit.md

File metadata and controls

38 lines (28 loc) · 490 Bytes

avoid_public_properties_on_bloc_and_cubit

severity: WARNING

Avoid public properties on Bloc and Cubit, prefer emit state or use private value.

Example:

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;
}