Skip to main content

avoid-instantiating-in-bloc-value-provider

added in: 1.25.0
Free+

Warns when a BlocProvider.value returns a new instance instead of reusing an existing one.

Example

❌ Bad:

BlocProvider.value(
value: RegularService(), // LINT: Avoid creating a new instance. Try providing an existing one instead.
);

✅ Good:

BlocProvider.value(
value: existingInstance,
);

Additional Resources