linter
linter copied to clipboard
`use_key_in_widget_constructors` shouldn't be emitted when widget is marked with `@visibleForTesting`
Describe the issue
Currently, converting a private widget that has no key parameter to a @visibleForTesting widget with no key parameter will trigger use_key_in_widget_constructors.
There's no reason for use_key_in_widget_constructors to be emitted in this case, as the widget is not supposed to be used outside of the library it has been defined anyway.
To Reproduce
With use_key_in_widget_constructors enabled, the following code emits a warning:
@visibleForTesting
final class PrivateWidget extends StatelessWidget {
const PrivateWidget();
Widget build(BuildContext context) => const SizedBox.shrink();
}
Expected behavior As the widget is virtually private and is not supposed to be used outside the defining library, the lint should not be emitted.