58 lines
1.6 KiB
Dart
58 lines
1.6 KiB
Dart
import "operations/trip.dart";
|
|
|
|
class BRRState {
|
|
final List<Trip> trips;
|
|
final String? scheduleFileName;
|
|
final DateTime? uploadedAt;
|
|
final String? routeInfo; // e.g., "Metropolitan Line - Uxbridge"
|
|
final String? serviceDate; // "21/09/2025"
|
|
|
|
BRRState({
|
|
this.trips = const [],
|
|
this.scheduleFileName,
|
|
this.uploadedAt,
|
|
this.routeInfo,
|
|
this.serviceDate,
|
|
});
|
|
|
|
BRRState copyWith({
|
|
List<Trip>? trips,
|
|
String? scheduleFileName,
|
|
DateTime? uploadedAt,
|
|
String? routeInfo,
|
|
String? serviceDate,
|
|
}) {
|
|
return BRRState(
|
|
trips: trips ?? this.trips,
|
|
scheduleFileName: scheduleFileName ?? this.scheduleFileName,
|
|
uploadedAt: uploadedAt ?? this.uploadedAt,
|
|
routeInfo: routeInfo ?? this.routeInfo,
|
|
serviceDate: serviceDate ?? this.serviceDate,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
"trips": trips.map((trip) => trip.toJson()).toList(),
|
|
"scheduleFileName": scheduleFileName,
|
|
"uploadedAt": uploadedAt?.toIso8601String(),
|
|
"routeInfo": routeInfo,
|
|
"serviceDate": serviceDate,
|
|
};
|
|
}
|
|
|
|
factory BRRState.fromJson(Map<String, dynamic> json) {
|
|
return BRRState(
|
|
trips: (json["trips"] as List?)
|
|
?.map((tripJson) => Trip.fromJson(tripJson as Map<String, dynamic>))
|
|
.toList() ??
|
|
[],
|
|
scheduleFileName: json["scheduleFileName"] as String?,
|
|
uploadedAt: json["uploadedAt"] != null
|
|
? DateTime.parse(json["uploadedAt"] as String)
|
|
: null,
|
|
routeInfo: json["routeInfo"] as String?,
|
|
serviceDate: json["serviceDate"] as String?,
|
|
);
|
|
}
|
|
}
|