prefer-multi-provider
Warns when multiple nested Providers can be replaced with MultiProvider
instead.
Replacing with multi provider improves the readability and reduces the widget tree nesting level.
Example
❌ Bad:
// LINT: Prefer 'MultiProvider' instead of multiple nested providers.
final provider = Provider(
create: () => RegularService(),
child: Provider(
create: () => RegularService(),
child: ListenableProvider(
create: () => RegularService(),
child: Widget(),
),
),
);
✅ Good:
final multiProvider = MultiProvider(
providers: [
Provider(create: () => RegularService()),
Provider(create: () => RegularService()),
ListenableProvider(create: () => RegularService()),
],
child: Widget(),
);