NextBuses.fromJson constructor

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

Creates a new NextBuses instance from a JSON object.

Implementation

factory NextBuses.fromJson(Map<String, dynamic> json) {
  return NextBuses(
    stopName: json[ApiFields.stopName] ?? '',
    predictions: ((json[ApiFields.predictions] as List?) ?? [])
        .map((prediction) => Prediction.fromJson(prediction))
        .toList(),
  );
}