MO-Fuel-Tax-Back/lib/models/vehicle.dart
2026-08-08 08:22:14 -05:00

48 lines
1.1 KiB
Dart

class Vehicle {
final String id;
final String make;
final String model;
final String color;
final String licensePlate;
Vehicle({
required this.id,
required this.make,
required this.model,
required this.color,
required this.licensePlate,
});
String get displayName => '$color $make $model ($licensePlate)';
Vehicle copyWith({
String? make,
String? model,
String? color,
String? licensePlate,
}) {
return Vehicle(
id: id,
make: make ?? this.make,
model: model ?? this.model,
color: color ?? this.color,
licensePlate: licensePlate ?? this.licensePlate,
);
}
Map<String, dynamic> toJson() => {
'id': id,
'make': make,
'model': model,
'color': color,
'licensePlate': licensePlate,
};
factory Vehicle.fromJson(Map<String, dynamic> json) => Vehicle(
id: json['id'] as String,
make: json['make'] as String,
model: json['model'] as String,
color: json['color'] as String,
licensePlate: json['licensePlate'] as String,
);
}