https://github.com/viniciusamelio/ez_either
A package to handle either with ease and simplicity
https://github.com/viniciusamelio/ez_either
dart either fluter
Last synced: 2 months ago
JSON representation
A package to handle either with ease and simplicity
- Host: GitHub
- URL: https://github.com/viniciusamelio/ez_either
- Owner: viniciusamelio
- License: other
- Created: 2022-02-23T22:30:39.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-22T11:53:07.000Z (almost 3 years ago)
- Last Synced: 2025-02-14T13:36:20.404Z (4 months ago)
- Topics: dart, either, fluter
- Language: Dart
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Ez_Either
Most times I add packages such as fpdart to my projects and I notice that the only thing I am really using in my code is Either. To solve this, I'm creating this package that is nothing but a simpler version of Either.
## Installing
```yaml
# pubspec.yaml
dependencies:
ez_either: ^1.0.0 # Check out the latest version
```## Usage
You should use Either when your code can return two different types, a Right (That should be the type you need to keep your business flow going on) and a Left (A exception, error or something that will need to be handled)
```dart
import "package:ez_either:ez_either.dart";// It is recommended to extract value using fold
final Either userOrFailure = Right(UserDto());print(either.isRight()); // true
print(either.isLeft()); // falsefinal result = usersOrFailure.fold(
(left) => left,
(right) => right,
);
```