Skip to content

update discarded_futures lint rule to not trigger when a widget expect a futur #59455

Closed
@stephane-archer

Description

@stephane-archer

Steps to reproduce

in the following code:

  @override
  Widget build(BuildContext context) {
    LutFoldersProvider lutFoldersProvider = Provider.of<LutFoldersProvider>(
      context,
    );
    return FutureBuilder<List<DirectoryTree>>(
      future: _getDirectoryTrees(lutFoldersProvider.lutFolders),
      builder:
          (BuildContext context, AsyncSnapshot<List<DirectoryTree>> snapshot) {
        if (snapshot.hasError) {

I get the following warning:

Asynchronous function invoked in a non-'async' function.
Try converting the enclosing function to be 'async' and then 'await' the future.

but future is expecting a Future<List<DirectoryTree>>? so this warning doesn't make sense in that case.
I will not await the futur.
So discarded_futures lint rule should be updated to allow this use case.

Expected results

see up

Actual results

see up

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.6, on macOS 13.4.1 22F770820d darwin-x64, locale en-GB)
    • Flutter version 3.19.6 on channel stable at /Users/fractale/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (3 days ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/fractale/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.88.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.86.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.4.1 22F770820d darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 124.0.6367.61

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

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-positivetype-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