Closed MuthuHere closed 4 years ago
nothing weird, you're just returning from closure not function
how you mean? any clue ? @krevedkokun
it's hard to tell what you're trying to achieve from that snippet, but my guess is that you should return response.fold
Here you go,
This is a class to return loginResponse once it get success i am returning LoginModel if not i am returning error.
Hi! As @krevedkokun said, you need to return
the result of fold
. Your current code should produce a warning about not returning a proper value from userLogin
– that's probably what the yellow squiggly line is about.
This is normal and expected in Dart. The Dart language doesn't have non-local returns.
@spebbe yes, got it but it gives error :-(
I'm not sure what you are trying to do here, but please check your types in your editor of choice, as they do not currently line up correctly. data
can never be of runtime type LoginModel
. Your should be able to return response.fold(...)
directly, although some additional type annotations might be necessary.
I highly recommend adding pedantic
or extra_pedantic
to your project. They will help you spot a lot of problems statically, including type issues like these.
In my api call i am returning response object in right and error message in left.
See i am getting the print line execution. Quite weird