identityFuture< T> function
Returns the given a
, wrapped in Future.value
.
Same as idFuture
.
Shortcut function to return the input parameter:
final either = Either<String, int>.of(10);
/// Without using `identityFuture`, 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`, the function just returns its input parameter.
final withIdentityFuture = either.match(identityFuture, (r) async => '$r');
Implementation
Future<T> identityFuture<T>(T a) => Future.value(a);