call method

Future<T> call()

Allows calling a Future<Option<T>> value like a function, transforming it into a Future that unwraps the returned Option value.

Warning: This is an unsafe operation. An OptionError will be thrown if this operation is used on a Future returning a None value when that Future completes. You can take advantage of this safely via catchOptionAsync.

Future<Option<int>> optionReturn() async {
  return Some(1);
}

int foo = await optionReturn()();

print(foo) // prints: 1

See also: Rust: Option::unwrap()

Implementation

Future<T> call() async => (await this).unwrap();