BusIncident.fromJson constructor

BusIncident.fromJson(
  1. Map<String, dynamic> json
)

Creates a BusIncident object from a JSON object.

Implementation

factory BusIncident.fromJson(Map<String, dynamic> json) {
  return BusIncident(
    timeOfLastUpdate:
        DateTime.tryParse(json[ApiFields.dateUpdated] ?? '') ?? emptyDateTime,
    description: json[ApiFields.description] ?? '',
    incidentId: json[ApiFields.incidentId] ?? '',
    incidentType: json[ApiFields.incidentType] ?? '',
    affectedRoutes: List<String>.from(json[ApiFields.routesAffected] ?? []),
  );
}