NavigationManeuver.fromJson constructor

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

Implementation

NavigationManeuver.fromJson(Map<String, dynamic> json) {
  bearingBefore = (json['bearing_before'] as num?)?.toInt();
  bearingAfter = (json['bearing_after'] as num?)?.toInt();
  instruction = json['instruction'] as String?;

  if (json.containsKey('location') && json['location'] != null) {
    location = List<double>.from(
      json['location'] as List<dynamic>,
    );
  }

  if (json.containsKey('modifier') && json['modifier'] != null) {
    switch (json['modifier'] as String?) {
      case 'uturn':
        modifier = NavigationManeuverModifier.UTURN;
        break;
      case 'sharp_right':
        modifier = NavigationManeuverModifier.SHARP_RIGHT;
        break;
      case 'right':
        modifier = NavigationManeuverModifier.RIGHT;
        break;
      case 'slap_right':
        modifier = NavigationManeuverModifier.SLIGHT_RIGHT;
        break;
      case 'sharp_left':
        modifier = NavigationManeuverModifier.SHARP_LEFT;
        break;
      case 'left':
        modifier = NavigationManeuverModifier.LEFT;
        break;
      case 'slap_left':
        modifier = NavigationManeuverModifier.SLIGHT_LEFT;
        break;
      case 'straight':
        modifier = NavigationManeuverModifier.STRAIGHT;
        break;
    }
  }
  if (json.containsKey('type') && json['type'] != null) {
    switch (json['type'] as String?) {
      case 'turn':
        type = NavigationManeuverType.TURN;
        break;
      case 'new name':
        type = NavigationManeuverType.NEW_NAME;
        break;
      case 'depart':
        type = NavigationManeuverType.DEPART;
        break;
      case 'arrive':
        type = NavigationManeuverType.ARRIVE;
        break;
      case 'merge':
        type = NavigationManeuverType.MERGE;
        break;
      case 'on ramp':
        type = NavigationManeuverType.ON_RAMP;
        break;
      case 'off ramp':
        type = NavigationManeuverType.OFF_RAMP;
        break;
      case 'fork':
        type = NavigationManeuverType.FORK;
        break;
      case 'end of road':
        type = NavigationManeuverType.END_OF_ROAD;
        break;
      case 'continue':
        type = NavigationManeuverType.CONTINUE;
        break;
      case 'roundabout':
        type = NavigationManeuverType.ROUNDABOUT;
        break;
      case 'rotary':
        type = NavigationManeuverType.ROTARY;
        break;
      case 'roundabout turn':
        type = NavigationManeuverType.ROUNDABOUT_TURN;
        break;
      case 'notification':
        type = NavigationManeuverType.NOTIFICATION;
        break;
      case 'exit roundabout':
        type = NavigationManeuverType.EXIT_ROUNDABOUT;
        break;
      case 'exit rotary':
        type = NavigationManeuverType.EXIT_ROTARY;
        break;
    }
  }
}