class RideOptionModel { final int id; final String name; final String bordercolor; final double duration; final double price; final int seats; final DateTime timestmp; final bool archive; RideOptionModel({ required this.id, required this.name, required this.bordercolor, required this.duration, required this.price, required this.seats, required this.timestmp, required this.archive, }); factory RideOptionModel.fromJson(Map json) { return RideOptionModel( id: json['id'] ?? 0, name: json['name'] ?? '', bordercolor: json['bordercolor'] ?? '#000000', duration: (json['duration'] ?? 0).toDouble(), price: (json['price'] ?? 0).toDouble(), seats: json['seats'] ?? 0, 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, 'bordercolor': bordercolor, 'duration': duration, 'price': price, 'seats': seats, 'timestmp': timestmp.toIso8601String(), 'archive': archive, }; } }