toResult method

Future<Result<T, AppError>> toResult()

Implementation

Future<Result<T, AppError>> toResult() async {
  try {
    final data = await this;
    return Ok(data);
  } catch (e) {
    return Err(
      ExceptionHandler.handle(e is Exception ? e : Exception(e.toString())),
    );
  }
}