flutter-geocoding
flutter-geocoding copied to clipboard
[Bug]: Providing wrong country code for USA locations when trying to fetch details from India location
Please check the following before submitting a new issue.
- [x] I have searched the existing issues.
- [X] I have carefully read the documentation and verified I have added the required platform specific configuration.
Please select affected platform(s)
- [X] Android
- [X] iOS
Steps to reproduce
- call placemarkFromCoordinates() with latitude 37.09024 & longitude -95.712891
- it's a coordinate for USA location, but it's giving isoCountryCode as "IN" when i'm trying to fetch details from India
Note: It's happening only when i'm working with it on india location, if i'm doing from USA location then it's working fine
Expected results
it should provide country code as "US" for any USA location
Actual results
it's giving "IN" for any USA location if i'm calling the function on an application running in India
Code sample
Code sample
getLocationDetails(BuildContext context, String placeId) async {
debugPrint(placeId);
final gPlace.DetailsResponse? details =
await googlePlace.details.get(placeId, language: "en");
predictions = [];
List<Placemark> placemarks = await placemarkFromCoordinates(
_startPosition!.geometry!.location!.lat!,
_startPosition!.geometry!.location!.lng!,
localeIdentifier: "en");
_userCountry = placemarks[0].country;
_locality = placemarks[0].street;
_postalCode = placemarks[0].postalCode;
_latitude = "${_startPosition!.geometry!.location!.lat}";
_longitude = "${_startPosition!.geometry!.location!.lng}";
_userCoutryCode = placemarks[0].isoCountryCode;
debugPrint(
"Show country code: ${placemarks[0].isoCountryCode} ${details.result!.addressComponents![0].shortName}");
_userState = placemarks[0].administrativeArea;
_userCity = placemarks[0].locality! == ""
? placemarks[0].subLocality! == ""
? placemarks[0].name
: placemarks[0].subLocality!
: placemarks[0].locality!;
FocusScope.of(context).requestFocus(FocusNode());
notifyListeners();
}
Screenshots or video
Screenshots or video demonstration
[Upload media here]
Version
3.0.0
Flutter Doctor output
Doctor output
PS D:\Projects\travmeds2.0> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3593], locale en-IN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these
components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
- If there are multiple build tool versions available, install the latest
C++ CMake tools for Windows
Windows 10 SDK
[√] Android Studio (version 2023.3)
[√] IntelliJ IDEA Ultimate Edition (version 2023.3)
[√] VS Code, 64-bit edition (version 1.85.1)
[√] Connected device (3 available)
[√] Network resources
! Doctor found issues in 1 category.