Model.fromJson constructor
Constructs model from JSON.
Parses created_at and updated_at safely.
Implementation
Model.fromJson(Map<String, dynamic> json) {
id = json['id'] as int?;
uuid = json['uuid'] as String?;
if (json['created_at'] != null) {
try {
createdAt = DateTime.parse(json['created_at'] as String);
} catch (e) {
createdAt = null;
}
}
if (json['updated_at'] != null) {
try {
updatedAt = DateTime.parse(json['updated_at'] as String);
} catch (e) {
updatedAt = null;
}
}
}