Questions tagged [dartz]

functional programming library in dart

41 questions
1
vote
1 answer

json_serializable flutter parse and map with key connect with modal and mapper

Thais is my json format "recommended": { "section_title": "Recommended", "section_sub_title": "Recommended", "data": { "Allahabad": [ { "gym_id": "9", …
1
vote
1 answer

Flutter bloc 8 some error in Either / fold return with async

I am migrating my project to the new version of Flutter and I use the BloC package. As you know Bloc has been updated and it has changed most of its code, so now I am adapting mine, but I have some bugs. The argument type 'Future Function(bool)'…
Daniel Roldán
  • 1,328
  • 3
  • 20
1
vote
0 answers

when should i let the application crash?

i have two questions: Firstly when should i let the application crash? Secondly: this code from resoCoder. i do NOT understand it!!!!!!!!!!!! how could he crash the app if the todos is not right?! T getOrCrash() { // id = identity - same as…
1
vote
0 answers

How to cast Right side of Either to generic type in flutter

I have an extension to Task (from the dartz package) which looks like this extension TaskX, U> on Task { Task> mapLeftToFailure() { return this.map( // Errors are returned as objects …
Manu
  • 372
  • 2
  • 12
1
vote
1 answer

How can I define a return type of a lambda function in Dart?

I try to create a repository with type safe parameters. For this, I created the function parameter as a typedef and use the Dartz package, to be able to return either a failure or the desired result. The issue is, that I have to create a specific…
Tyx
  • 33
  • 4
1
vote
1 answer

How To Access The Failed Value From Either?

In the example below, we have: Type: Either, int> If No Error: right(number) If Error: left(RangedNumberValueFailuresAbstract.invalidNumber(failedNumberValue: number)) If we need to access the…
Erezahr
  • 21
  • 4
1
vote
0 answers

dartz: exception in function is not caught in attempt

I am using dartz with flutter. I want to use Either type with all API calls as suggested in this article Below is the way I have wrapped API to Task Future> receiveOtp( String phoneNumber) async { return…
harishr
  • 17,807
  • 9
  • 78
  • 125
0
votes
1 answer

is dartz Either Nesisty or just matter of taste?

So before I start I,m a beginner in Flutter and in programming all together. I used to just follow video tutorials and consider their best practices, one of my earliest tutorials introduced me to the Dartz library and it was used when getting data…
0
votes
1 answer

With the dartz Dart lib, how can you construct an IMap from key-value pairs?

I see the factory constructor factory IMap.fromPairs(FoldableOps> foldableOps, Order kOrder), but how do you use FoldableOps to be able to pass an Iterable> into it?
voxoid
  • 1,164
  • 1
  • 14
  • 31
0
votes
1 answer

With dartz is it possible to pass a failure on to the function that is folding my either

I have the following code class GetAuthUserUseCase { final AuthRepository _authRepository; GetAuthUserUseCase({ required AuthRepository authRepository, }) : _authRepository = authRepository; Future> call()…
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
0
votes
0 answers

How to use Either/DartZ with null Safety flutter

I'm trying to do some tests on my project in clean architecture using Dartz: My entity class: // ignore_for_file: public_member_api_docs, sort_constructors_first class User { final String fullname; final String email; final String password; …
0
votes
0 answers

return '> rather than

Erro: Expected: Right: Actual: '> package:test_api …
0
votes
1 answer

Receiving from a .fold "emit was called after an event handler completed normally."

Since I found the solution hidden of my problem in the comments, I am putting it here in a more prominent place: Problem: I received the above error after awaiting some function within a Dart .fold method. _failureOrProperty.fold( …
w461
  • 2,168
  • 4
  • 14
  • 40
0
votes
1 answer

How to initialize Either Right to an empty value in flutter - Reloaded

How do I correctly initialize my Either object in the following code? class JobListState extends Equatable { const JobListState({ this.status = JobListStatus.initial, this.jobListSections = Right([]), this.filter, }); final…
w461
  • 2,168
  • 4
  • 14
  • 40
0
votes
1 answer

Type 'Right' is not a subtype of type 'String?' in type cast

I'm trying to get the String 'bairro' from this part of code: var infoCepJSON = await viaCepSearchCep.searchInfoByCep(cep: '$_cep') But, its return a Type Either. How can I get the string bairro in this case? If I put: …