idFuture<T> function

Future<T> idFuture<T>(
  1. T a
)

Returns the given a, wrapped in Future.value.

Same as identityFuture.

Shortcut function to return the input parameter:

final either = Either<String, int>.of(10);

/// Without using `idFuture`, you must write a function to return
/// the input parameter `(l) async => l`.
final noId = await either.match((l) async => l, (r) async => '$r');

/// Using `identityFuture`/`idFuture`, the function just returns its input parameter.
final withIdentity = either.match(identityFuture, (r) async => '$r');
final withId = await either.match(idFuture, (r) async => '$r');

Implementation

Future<T> idFuture<T>(T a) => Future.value(a);