avoid_unnecessary_consumer_widgets
v0.1.0 Warning Fix Widget Best Practices
This rule detects ConsumerWidget subclasses where the WidgetRef parameter is never used inside the build method. If you are not reading or watching any providers, there is no reason to use ConsumerWidget over a plain StatelessWidget.
Why use this rule
Section titled “Why use this rule”Every ConsumerWidget subscribes to the Riverpod container, which means it participates in the provider dependency graph even when it does not need to. Switching to StatelessWidget removes that overhead, makes the widget’s dependencies explicit (it has none), and signals to other developers that this widget is purely presentational.
See also: ConsumerWidget
// ConsumerWidget with unused ref parameterclass Greeting extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { // ref is never used return Text('Hello'); }}// StatelessWidget since no providers are neededclass Greeting extends StatelessWidget { @override Widget build(BuildContext context) { return Text('Hello'); }}Configuration
Section titled “Configuration”To disable this rule:
plugins: many_lints: diagnostics: avoid_unnecessary_consumer_widgets: false