functional programming library in dart
Questions tagged [dartz]
41 questions
9
votes
1 answer
In Freezed is it possible to create union cases from already existing freezed dataclasses
I am using the freezed package to create my json parsers and data classes. As of now I am using dartz's package to create Union cases and handle them in Flutter widgets. For example some of my Union classes looks like the…

Abhilash Chandran
- 6,803
- 3
- 32
- 50
7
votes
0 answers
How to avoid nested fold in when calling multiple Future with DartZ?
I have a piece of code that look like this:
final Either resA = await deleteA();
resA.fold(
(failure) => handleFailure(),
(success) async {
final Either resB = await deleteB();
resB.fold(
(failure) =>…

Manu
- 372
- 2
- 12
5
votes
1 answer
what is the difference between either and Option in dartz?
i am trying to understand dartz, but the documentation is not clear enough.
i need to get the difference between either and Option in dartz?
abstract class Option implements TraversableMonadPlusOps
user15543853
3
votes
2 answers
Flutter Bloc Error : emit was called after an event handler completed normally - between two functions
I have the following problem...
emit was called after an event handler completed normally. This is
usually due to an unawaited future in an event handler. Please make
sure to await all asynchronous operations with event handlers and use
emit.isDone…

Daniel Roldán
- 1,328
- 3
- 20
3
votes
1 answer
Dartz - get left of Either
var newRight;
if(either.isRight()) {
newRight = either.getOrElse(() => throw UnimplementedError());
} else {
return Left(either.fold((f) => f, (r) => throw UnimplementedError()))
}
How can I get left side of either and return it as in the…

Chris
- 839
- 1
- 12
- 30
2
votes
1 answer
Dartz, flutter test - Can't get a Right part of Future>, instead of that - instance of Future> as a actual result
This is my first try to write a test. I use the Dartz package and I don't know how to get just one part as a result of my test. The error is:
Expected: Right:
Actual:

Veronika Haichenko
- 150
- 1
- 1
- 7
2
votes
0 answers
Flutter test , stubbing a method that uses dartz fails
Here's the implicated methods of the cubit I'm testing:
void authCheck() {
if (_authUser != null) {
emit(AuthState.authenticated(_authUser!));
if (kDebugMode) {
// ignore: avoid_print
print(_authUser!);
}
…

cerealex
- 1,649
- 4
- 17
- 37
2
votes
1 answer
flutter -bloc - how to resolve Failed Assertion : !_isComplete
I am stuck at this exception .
I am trying to create a Number Trivia app based on course on you tube
basically i'm handling errors and exceptions with Either class from dartz library;
on((event, emit) async {
…

R3HP
- 470
- 4
- 13
2
votes
2 answers
How to initialize Either Right to an empty value in flutter
I recently made the switch to null-safety in my flutter project, which brings a new kind of problem when using the Either type (from the dartz package)
For example, before I would have some properties in my class like this:
Either

Manu
- 372
- 2
- 12
2
votes
1 answer
Fix Dartz package with non nullable
I moved my project to the sdk 2.12 and trying to update my code with the non-nullable crap.
Now I don't understand how to fix things in Dartz package...
Example:
import 'package:dartz/dartz.dart';
import 'package:mobile_100asa/http.dart';
class…

Ayeye Brazo
- 3,316
- 7
- 34
- 67
2
votes
1 answer
How to refactor functional error handling in flutter with dartz
I have two methods
@override
Future

loki
- 2,271
- 5
- 32
- 46
2
votes
1 answer
Dartz Right containing List throws Error when comparing with expect() function
Simple code like this
expect(Right(['Two', 'Three']), equals(Right(['Two', 'Three'])));
throws error:
ERROR: Expected: Right:
Actual: Right:
What am I doing wrong? Both lists…

Adam Smaka
- 5,977
- 3
- 50
- 55
2
votes
1 answer
Getting Option> unpacked in Flutter
In my bloc state I have this:
Option>> optionFailureOrStream,
It' can be empty (Option) or have an error or a stream.
In my bloc I yielding this with optionOf like this:
yield state.copyWith(optionFailureOrStream:…

Mark
- 7,507
- 12
- 52
- 88
2
votes
0 answers
With dartz Option> how to set to none
I am trying to use a type of Option and want to set this to a none() but this fails the error Invalid constant value.dart(invalid_constant).
How can I set a Option to a none or undefined state.
@freezed
abstract class InvitationsState…

Mark
- 7,507
- 12
- 52
- 88
1
vote
0 answers
How to cast both sides of Either?
I am trying to have Either where Concrete extends Abstract class, but I cannot get it to work. If I try to cast the left side I get the error:
type 'Right' is not a subtype of type 'Either' in…

Joaquim
- 111
- 1
- 10