import "operations/trip.dart"; class BRRState { final List 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? 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 toJson() { return { "trips": trips.map((trip) => trip.toJson()).toList(), "scheduleFileName": scheduleFileName, "uploadedAt": uploadedAt?.toIso8601String(), "routeInfo": routeInfo, "serviceDate": serviceDate, }; } factory BRRState.fromJson(Map json) { return BRRState( trips: (json["trips"] as List?) ?.map((tripJson) => Trip.fromJson(tripJson as Map)) .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?, ); } }