Result<T> constructor

  1. T computation()

Creates a Result with the result of calling computation.

This generates either a ValueResult with the value returned by calling computation, or an ErrorResult with an error thrown by the call.


factory Result(T Function() computation) {
  try {
    return ValueResult<T>(computation());
  } on Object catch (e, s) {
    return ErrorResult(e, s);