error_or 0.0.1 copy "error_or: ^0.0.1" to clipboard
error_or: ^0.0.1 copied to clipboard

outdated

A simple class for returning a value or an error

example/error_or_example.dart

import 'dart:math';

import 'package:error_or/error_or.dart';

Future<ErrorOr<String>> getValue() async {
  await Future.delayed(Duration(seconds: 1));
  if (Random().nextBool() == false) {
    return ErrorOr.error(Exception('Error'));
  }
  return ErrorOr.value('Success');
}

void main() async {
  final errorOr = await getValue();
  if (errorOr.hasError) {
    print(errorOr.error);
    return;
  }
  print(errorOr.value);
}
5
likes
0
points
69
downloads

Publisher

verified publisherapptakk.com

Weekly Downloads

A simple class for returning a value or an error

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on error_or