VroomVehicle.fromJson constructor

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

Generates a VroomVehicle from a Map having keys matching the Vroom API Vehicle model that includes:

'id', 'profile', 'description', 'start', 'start_index', 'end', 'end_index', 'capacity', 'skills', 'time_window', 'breaks', 'speed_factor', 'max_tasks', 'steps'.

Implementation

factory VroomVehicle.fromJson(Map<String, dynamic> json) => VroomVehicle(
      id: json['id'],
      profile: json['profile'],
      description: json['description'],
      start: ORSCoordinate.fromList(json['start']),
      startIndex: json['start_index'],
      end: ORSCoordinate.fromList(json['end']),
      endIndex: json['end_index'],
      capacity: json['capacity'] == null
          ? null
          : (json['capacity'] as List<dynamic>)
              .map<int>((dynamic e) => e as int)
              .toList(),
      skills: json['skills'] == null
          ? null
          : (json['skills'] as List<dynamic>)
              .map<int>((dynamic e) => e as int)
              .toList(),
      timeWindow: json['time_window'] == null
          ? null
          : (json['time_window'] as List<dynamic>)
              .map<int>((dynamic e) => e as int)
              .toList(),
      breaks: json['breaks'] == null
          ? null
          : (json['breaks'] as List<dynamic>)
              .map<VroomVehicleBreak>(
                (dynamic e) => VroomVehicleBreak.fromJson(e),
              )
              .toList(),
      speedFactor: json['speed_factor'],
      maxTasks: json['max_tasks'],
      steps: json['steps'] == null
          ? null
          : (json['steps'] as List<dynamic>)
              .map<VroomVehicleStep>(
                (dynamic e) => VroomVehicleStep.fromJson(e),
              )
              .toList(),
    );