call method

Future<T> call()

Allows calling a FutureOr<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 FutureOr returning a None value when that FutureOr completes. You can take advantage of this safely via catchOptionAsync.

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

int foo = await optionReturn()();

print(foo) // prints: 1

See also: Rust: Option::unwrap()

Implementation

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