I am trying to do a Redux logger. I am new to Flutter.
I installed redux_logging package but in my case it just prints Instance of <NameOfClass>
As for what I am reading in this answer, I could print the data, but need to use toJson and fromJson in my class. This is it, simplified
@immutable
class FetchState {
final bool isError;
final bool isLoading;
FetchState({
this.isError,
this.isLoading,
});
factory FetchState.initial() => FetchState(
isLoading: false,
isError: false,
);
FetchState copyWith({
@required bool isError,
@required bool isLoading,
}) {
return FetchState (
isError: isError ?? this.isError,
isLoading: isLoading ?? this.isLoading
);
}
}
How and where do I add toJson and fromJson in order to be able to print the variables in the instance using json.encode(fetchState)
(where fetchState is an instance of FetchState I suppose)
Thank you