flutterbuddy1 / geocoder_buddy

Forward, Reverse geocoding and Search Address without any apikey.
MIT License
7 stars 20 forks source link

GBData errors with some address fields #1

Open payner35 opened 2 years ago

payner35 commented 2 years ago

I live in Dubai.. so the results are default not in english. Plus some of the address fields come back as Null.. causing a String error. This will fix that in GBData.dart

factory Address.fromJson(Map<String, dynamic> json) => Address( road: json['road'] ?? "", village: json["village"] ?? "", county: json["county"] ?? "", stateDistrict: json["state_district"] ?? "", state: json["state"] ?? "", iso31662Lvl4: json["ISO3166-2-lvl4"] ?? "", postcode: json["postcode"] ?? "", country: json["country"] ?? "", countryCode: json["country_code"] ?? "", );

To fix the lang... you can add a &accept-language=en

var request = http.Request( 'GET', Uri.parse( '$PATH/reverse?lat=${pos.latitude}&lon=${pos.longitude}&accept-language=en&format=jsonv2'));

jtmuller5 commented 1 year ago

@payner35 You can use my fork which makes all fields nullable:

geocoder_buddy:
    git:
      url: https://github.com/jtmuller5/geocoder_buddy