class Geocode {
  List<AddressComponent>? addressComponents;
  String? formattedAddress;
  Geocode({
    this.addressComponents,
    this.formattedAddress,
  });

  Geocode.fromJson(Map<String, dynamic> json) {
    formattedAddress = json['formatted_address'];
    if (json['address_components'] != null) {
      addressComponents = [];
      json['address_components'].forEach((v) {
        addressComponents!.add(AddressComponent.fromJson(v));
      });
    }
  }
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['formatted_address'] = formattedAddress;
    if (addressComponents != null) {
      data['address_components'] =
          addressComponents!.map((e) => e.toJson()).toList();
    }
    return data;
  }
}

class AddressComponent {
  String? longName;
  String? shortName;
  List<String>? types;
  AddressComponent({this.longName, this.shortName, this.types});

  AddressComponent.fromJson(Map<String, dynamic> json) {
    longName = json['long_name'];
    shortName = json['short_name'];
    types = json['types'].cast<String>();
  }
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['long_name'] = longName;
    data['short_name'] = shortName;
    data['type'] = types;
    return data;
  }
}
