prefer-correct-bloc-provider
Warns when a Bloc
is provided not with a BlocProvider
.
If you use both bloc
and provider
packages it becomes easy to accidentally use the wrong Provider
for your Blocs
.
Example
❌ Bad:
// LINT: Prefer providing 'Blocs' via 'BlocProvider'.
final provider = Provider<BlocA>(
create: (context) => BlocA(),
child: Widget(),
);
✅ Good:
final blocProvider = BlocProvider<BlocA>(
create: (context) => BlocA(),
child: Widget(),
);