Files
sdk/tests/lib/async
Lasse R.H. Nielsen 9f70bc7c1b Add Future.syncValue(T value) constructor.
There is currently no way to create a future with a specific value
that doesn't accept a `FutureOr` argument, and tries to flatten it.

The `Future.syncValue(T value)` constructor does not accept a
`Future<T>`, which makes it easier to control the type and argument.
It may also be more efficient than constructors which need to first
check if the argument is a `Future<T>` (and `_Future<T>`) first.
You shouldn't create a `Future<Future<Object>>`, but you might for
testing, and this constructor makes that easier too.

(It should really be called `Future.value`, but that name was taken
by what should probably have been `Future.new`.)

See https://dartbug.com/59814 for performance considerations.

CoreLibraryReviewExempt: No platform specific code or new functionality.
Change-Id: Ib5728055a06b20433dcd448ca7ad1baa54ec681c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451022
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-09-24 06:40:52 -07:00
..