decodeTrips static method
Implementation
static Trips? decodeTrips(Object? mapInput){
if(mapInput == null || !(mapInput is Map?)){
return null;
}
try {
Map map = mapInput as Map;
String? id = map['id'];
String? trip_state = map['trip_state'];
var total_distance = map['total_distance'];
var total_duration = map['total_duration'];
var total_elevation_gain = map['total_elevation_gain'];
var metadata = map['metadata'];
User? user = JsonDecoder.decodeUser(map['user']);
String? started_at = map['started_at'];
String? ended_at = map['ended_at'];
String? created_at = map['created_at'];
String? updated_at = map['updated_at'];
List? eventsMapList = map['events'];
List<Events?>? events = List.empty(growable: true);
eventsMapList?.forEach((map) {
events.add(JsonDecoder.decodeEvents(map));
});
List? stopsMapList = map['stops'];
List<Stop?>? stops = List.empty(growable: true);
stopsMapList?.forEach((map) {
stops.add(JsonDecoder.decodeStop(map));
});
String? syncStatus = map['syncStatus'];
Trips? trips = Trips();
trips.id = id;
trips.tripState = trip_state;
trips.totalDistance = total_distance;
trips.totalDuration = total_duration;
trips.totalElevation_gain = total_elevation_gain;
trips.metadata = metadata;
trips.user = user;
trips.startedAt = started_at;
trips.endedAt = ended_at;
trips.createdAt = created_at;
trips.updatedAt = updated_at;
trips.events = events;
trips.stop = stops;
trips.syncStatus = syncStatus;
return trips;
} catch (error){
print('decodeTrips '+error.toString());
return null;
}
}