I'm using json_serializable for parsing Map<dynamic, dynamic> to my object.
Example:
@JsonSerializable()
class Todo {
String title;
bool done;
Todo(this.title, this.done);
factory Todo.fromJson(Map<String, dynamic> json) => _$TodoFromJson(json);
}
Because I'm getting 'done': 1 from the api, I get following error:
Unhandled Exception: type 'int' is not a subtype of type 'bool' in type cast
How can I cast 1 = true and 0 = false with json_serializable?