Skip to content

[lint] Specify the type of a local variable when the type is non-obvious on private types get bad result #62666

@stephane-archer

Description

@stephane-archer
      child: IconButton(
        icon: Icon(
          Icons.delete_outline,
          color: isProcessing
              ? Colors.grey.withValues(alpha: 0.3)
              : Colors.redAccent,
        ),
        onPressed: isProcessing
            ? null
            : () async {
                final favoriteFoldersNotifier =
                    ref.read(favoriteFoldersProvider.notifier);
                await favoriteFoldersNotifier.removeFavoriteFolders(folder);
              },
      ),

Specify the type of a local variable when the type is non-obvious. Try adding a type annotation.

apply quick fix:

      child: IconButton(
        icon: Icon(
          Icons.delete_outline,
          color: isProcessing
              ? Colors.grey.withValues(alpha: 0.3)
              : Colors.redAccent,
        ),
        onPressed: isProcessing
            ? null
            : () async {
                final AsyncNotifier<List<Directory>> favoriteFoldersNotifier =
                    ref.read(favoriteFoldersProvider.notifier);
                await favoriteFoldersNotifier.removeFavoriteFolders(folder);
              },
      ),

The method 'removeFavoriteFolders' isn't defined for the type 'AsyncNotifier'. Try correcting the name to the name of an existing method, or defining a method named 'removeFavoriteFolders'.

Here the type should be _FavoriteFoldersAsyncNotifierInterface. I think the lint gets confused because the type is private (it shouldn't)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-quick-fixIssues with analysis server (quick) fixestype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions