Skip to content

Add explicit discard for futures you don't want to await #46047

@gaaclarke

Description

@gaaclarke

This tracker is for issues related to: dart:async

Right now if you have the unawaited_futures linter turned on there isn't a way to not await an asynchronous operation without using linter ignores. Ideally there should be a way to explicitly disregard the asynchronous operation without resorting to using ignores or going for implicitly discarded futures.

For example:

Future<void> bar() {...}
void foo() {
  bar(); # linter error
}

becomes:

Future<void> bar() {...}
void foo() {
  bar().discard();
}

While one could create an extension method for future, it wouldn't be that helpful unless the autofix tools for linter errors suggested using discard(). For that it as to be built into the dart sdk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions