Giter Site home page Giter Site logo

epam-cross-platform-lab / dart_result_type Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 3.0 67 KB

๐Ÿ’Š Result Type for Dart represents either a success or a failure, including an associated value in each case.

Home Page: https://pub.dev/packages/result_type

License: Apache License 2.0

Dart 100.00%
dart flutter functional-programming result either types

dart_result_type's People

Contributors

minikin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dart_result_type's Issues

Empty return statement for Success?

Maybe there's an easy way to do this, but with this amazing package, I no longer need to return a bool internal to the class of whether it was a success or not. Is there any way to return Result<_, int> something like that. I don't need to return anything if Success. I suppose it doesn't hurt or do anything to just return Result<bool, int> and just return true, but was hoping to just clean up the code a bit for readability.

Add null safety support

  • Users want to use the package with dart 2.12.0+ and flutter 2.0.0+

We need to add support for null safety.

`result` doesn't return anything

Maybe I'm wrong but reading result documentation seems that it will return a new Result applying the appropriate function but it returns void. Something like a fold method.

/// Returns a new value of [Result] from closure
/// either a success or a failure.

If it isn't the expected behavior of the result, can you consider adding a fold method? Implementation should be like this:

Result<U, E> fold<U, E>(U Function(S) success, E Function(F) failure) {
  if (isSuccess) {
    final left = this as Success<S, F>;
    return Success(success(left.value));
  }

  final right = this as Failure<S, F>;
  return Failure(failure(right.value));
}

Cannot use with implicit-dynamic in analysis options

Describe the bug
It looks like I have to disable analysis that checks for implicit dynamic types in order to use this. Is this accurate? Is there a way to get around this?

To Reproduce
Example function:

Result<bool, Exception> test() {
  Success(true);
}

Expected behavior
No compiler errors or warnings

Actual behavior
Compiler error on call to Success:

(new) Success<bool, dynamic> Success(bool value)
package:result_type/src/success.dart

Missing type arguments for generic type 'Success<bool, dynamic>'.
Try adding an explicit type, or remove implicit-dynamic from your analysis options file.dart(implicit_dynamic_type)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.