Stop.fromJson constructor

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

Creates a Stop object from a JSON object.

Implementation

factory Stop.fromJson(Map<String, dynamic> json) {
  return Stop(
    latitude: ((json[ApiFields.latitude] ?? 0.0) as num).toDouble(),
    longitude: ((json[ApiFields.longitude] ?? 0.0) as num).toDouble(),
    name: json[ApiFields.name] ?? '',
    routes: ((json[ApiFields.routes] as List?) ?? [])
        .map((route) => route.toString())
        .toList(),
    stopId: int.parse((json[ApiFields.stopId] ?? '0') as String),
  );
}