result 1.0.4 copy "result: ^1.0.4" to clipboard
result: ^1.0.4 copied to clipboard

Object that represents either a success or a failure; 'success' or 'failure' for each case

example/main.dart

import 'package:result/result.dart';

main() {
  var s= Result.success(2);
  print(s.get()); // 2

  var ss = s.map(
    (x) => x + 1
  );
  print(ss.get()); // 3
 
  var f = Result.failure(Exception("exception"));
  print(f);//Result, failure

  var ff = f.map(
    (f) => Exception("another exception")
  );
  print(ff);// Result, failure

  worker() {
    //work staff
    throw Exception("work exception");
  }
  try {
    var r = Result(worker());
    r = r.get();
  } catch (e) {
    print(e); // work exception
  }
}
3
likes
40
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

Object that represents either a success or a failure; 'success' or 'failure' for each case

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

More

Packages that depend on result