NavigationInstructionPropertyComponent.fromJson constructor

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

Implementation

NavigationInstructionPropertyComponent.fromJson(Map<String, dynamic> json) {
  text = json['text'] as String?;
  abbr = json['abbr'] as String?;
  abbrPriority = (json['abbr_priority'] as num?)?.toInt();
  imageBaseURL = json['imageBaseURL'] as String?;
  active = json['active'] as bool?;

  if (json.containsKey('type') && json['type'] != null) {
    switch (json['type'] as String?) {
      case 'text':
        type = NavigationPropertyComponentType.TEXT;
        break;
      case 'icon':
        type = NavigationPropertyComponentType.ICON;
        break;
      case 'delimiter':
        type = NavigationPropertyComponentType.DELIMITER;
        break;
      case 'exit_number':
        type = NavigationPropertyComponentType.EXIT_NUMBER;
        break;
      case 'exit':
        type = NavigationPropertyComponentType.EXIT;
        break;
      case 'lane':
        type = NavigationPropertyComponentType.LANE;
        break;
    }
  }

  if (json.containsKey('directions') && json['directions'] != null) {
    directions = List<NavigationDirection>.from(
      (json['directions'] as List<dynamic>).map(
        (direction) {
          switch (direction as String) {
            case 'right':
              return NavigationDirection.RIGHT;
          }

          return NavigationDirection.LEFT;
        },
      ),
    );
  }
}