fromMap static method
Implementation
static LegStep fromMap(Map<String, dynamic> map) {
StepManeuver? maneuver;
if (map.containsKey('maneuver')) {
maneuver = StepManeuver.fromMap(map['maneuver']);
}
List<VoiceInstructions>? voiceInstructions;
if (map.containsKey('voiceInstructions')) {
List<dynamic> voiceInstructionsMap =
map['voiceInstructions'] as List<dynamic>;
voiceInstructions = List.generate(voiceInstructionsMap.length, (index) {
return VoiceInstructions.fromMap(
voiceInstructionsMap[index] as Map<String, dynamic>);
});
}
List<StepIntersection>? intersections;
if (map.containsKey('intersections')) {
List<dynamic> intersectionsMap = map['intersections'] as List<dynamic>;
intersections = List.generate(intersectionsMap.length, (index) {
return StepIntersection.fromMap(
intersectionsMap[index] as Map<String, dynamic>);
});
}
return LegStep(
distance: (map['distance'])?.toDouble(),
duration: (map['duration'])?.toDouble(),
geometry: map['geometry'],
name: map['name'],
destinations: map['destinations'],
mode: map['mode'],
pronunciation: map['pronunciation'],
rotaryName: map['rotary_name'],
rotaryPronunciation: map['rotary_pronunciation'],
maneuver: maneuver,
voiceInstructions: voiceInstructions,
drivingSide: map['driving_side'],
weight: (map['weight'])?.toDouble(),
intersections: intersections,
exits: map['exits'],
ref: map['ref'],
);
}