prefer-define-hero-tag
added in: 1.6.0
warning
Warns when a Widget
has an unset heroTag
.
When heroTag
is not set, the default value is used. Having two or more widgets with the same heroTag
will result in an error.
Example
❌ Bad:
FloatingActionButton(
onPressed: () => context.read<CounterCubit>().increment(),
child: const Icon(Icons.add),
); // LINT
✅ Good:
FloatingActionButton(
onPressed: () => context.read<CounterCubit>().increment(),
child: const Icon(Icons.add),
heroTag: 'increment_heroTag',
);