Skip to main content

avoid-bloc-public-methods

added in: 1.2.0
🛠
Pro+

Warns when a Bloc has public methods except the overridden ones.

Additional resources:

Example

❌ Bad:

class CounterBloc extends Bloc<CounterEvent, int> {
CounterBloc() : super(0);

// LINT
void changeSate(int newState) {
state = newState;
}


void onChange(Change<int> change) {
super.onChange(change);
print(change);
}

void _listenToChange() {}
}

✅ Good:

class CounterBloc extends Bloc<CounterEvent, int> {
CounterBloc() : super(0);


void onChange(Change<int> change) {
super.onChange(change);
print(change);
}

void _listenToChange() {}
}