Replies: 1 comment 2 replies
-
|
For generating the toMap and fromMap methods, you should add the json_serializable - https://pub.dev/packages/json_serializable Freezed is aware of the package. Add the json_serializable package to your pubspec file, add a part 'login_bloc.g.dart' then add a fromJson method as follows. factory LoginState.fromJson(Map<String, dynamic> json) => _$LoginStateFromJson(json);The caveat is it adds a key method to identify which constructor to call. Something like Be aware of this if you get the json from a server that may not have that key |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I had this state class
which after conversion according to my research and docs became
Now in my bloc I had this code before:
Now it is
Now the tricky part is for retrieving the data. Initially when using equatables it was:
This is the part I need help with. I need to access data in the LoginDataState and using map is very clear to me on how I can do this.
Beta Was this translation helpful? Give feedback.
All reactions