Skip to content

Support Synchronous evaluation of FutureOr #726

@creativecreatorormaybenot

Description

Feature request

When we have a variable FutureOr<int> futureOr, await futureOr should run synchronously when the variable is not a Future (see https://stackoverflow.com/q/59213196/6509751).

Current situation

At the moment, you need to use the following code if you want to run the evaluation synchronously when possible:

if (futureOr is int)
  print(futureOr + 9);
else
  print((await futureOr) + 9);

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProposed language feature that solves one or more problems

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions