okay 0.5.0 copy "okay: ^0.5.0" to clipboard
okay: ^0.5.0 copied to clipboard

Typesafe error-handling for dart . An implementation of rust's `Result` type in dart.

okay #

Typesafe, intuitive error-handling for dart . An implementation of rust's Result type in dart.

ci coverage pub package style: very good analysis License: MIT


Note: This package was heavily inspired by rustlang's result type.

Installation #

In the dependencies: section of your pubspec.yaml, add the following line:

dependencies:
  okay: <latest_version>

Usage #

import 'package:okay/okay.dart';

class FallibleOpSuccess {}
class FallibleOpFailure {}

Result<FallibleOpSuccess, FallibleOpFailure> fallibleOp() {
  if (true) {
    return ok(FallibleOpSuccess());
  } else {
    return err(FallibleOpFailure());
  }
}

final result = fallibleOp();

result.inspect((value) {
    print('Success with value: $value');
  }).inspectErr((error) {
    print('Failure with error: $error');
  });
}
16
likes
0
pub points
54%
popularity

Publisher

verified publisherhextools.0xba1.xyz

Typesafe error-handling for dart . An implementation of rust's `Result` type in dart.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

meta

More

Packages that depend on okay