Skip to content

use_key_in_widget_constructors shouldn't be emitted when widget is marked with @visibleForTesting #59365

@mateusfccp

Description

@mateusfccp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-false-positiveIssues related to lint rules that report a problem when it isn't a problem.linter-set-fluttertype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions