decodeStop static method

Stop? decodeStop(
  1. Object? mapInput
)

Implementation

static Stop? decodeStop(Object? mapInput){

  if(mapInput == null || !(mapInput is Map?)){
    return null;
  }

  try {
    Map map = mapInput as Map;

    String? id = map['id'];
    String? name = map['name'];
    String? description = map['description'];
    String? address = map['address'];
    var metadata = map['metadata'];
    var geometryRadius = map['geometry_radius'];
    String? createdAt = map['created_at'];
    String? updatedAt = map['updated_at'];
    String? arrivedAt = map['arrived_at'];
    String? departedAt = map['departed_at'];


    var geometryMap = map['geometry'];
    String? type = geometryMap?['type'];
    List? coordinates = geometryMap?['coordinates'];

    Geometry geometry = Geometry(type: type, coordinates: coordinates);

    Stop stop = Stop(
        id: id,
        name: name,
        description: description,
        address: address,
        metadata: metadata,
        geometryRadius: geometryRadius,
        createdAt: createdAt,
        updatedAt: updatedAt,
        arrivedAt: arrivedAt,
        departedAt: departedAt,
        geometry: geometry
    );
    return stop;
  } catch (error){
    print('decodeStop ' + error.toString());
    return null;
  }
}