class TaxiOptionModel { final int id; final String name; final String iconUrl; final DateTime timestmp; final bool archive; TaxiOptionModel({ required this.id, required this.name, required this.iconUrl, required this.timestmp, required this.archive, }); factory TaxiOptionModel.fromJson(Map json) { return TaxiOptionModel( id: json['id'] ?? 0, name: json['name'] ?? '', iconUrl: json['iconUrl'] ?? '#000000', timestmp: (json['timestamp'] ?? json['timestmp']) != null ? DateTime.fromMillisecondsSinceEpoch(json['timestamp'] ?? json['timestmp']) : DateTime.now(), archive: json['archive'] ?? false, ); } Map toJson() { return { 'id': id, 'name': name, 'iconUrl': iconUrl, 'timestmp': timestmp.toIso8601String(), 'archive': archive, }; } }