Search
 
SCRIPT & CODE EXAMPLE
 

DART

get user country automatically flutter

import 'dart:io' show Platform;
String localeName = Platform.localeName;
//output language_countryname => en_us
OR
geolocator: ^5.1.1
geocoder: ^0.2.1
Future<String> getCountryName() async {
    Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    debugPrint('location: ${position.latitude}');
    final coordinates = new Coordinates(position.latitude, position.longitude);
    var addresses = await Geocoder.local.findAddressesFromCoordinates(coordinates);
    var first = addresses.first;
    return first.countryName; // this will return country name
}

Comment

PREVIOUS NEXT
Code Example
Dart :: how to do type casting in dart for string 
Dart :: flutter showSnackBar replacme 
Dart :: flutter column 
Dart :: message yes or not in dart 
Dart :: string data to icon in flutter 
Dart :: flutter list to map 
Dart :: A dismissed Slidable widget is still part of the tree. 
Dart :: flutter map key/value 
Dart :: flutter open null safety 
Dart :: swicth statement in flutter 
Dart :: Determine the Screen size using the MediaQuery class Flutter 
Dart :: Error: java.io.IOException: No such file or directory in android 11 
Dart :: flutter otp input scrren 
Dart :: how to send sms in flutter 
Dart :: onboarding screen flutter 
Dart :: if else dart example 
Dart :: FloatingActionButton rtl flutter 
Dart :: Concatenate two list in Flutter 
Dart :: dart string equals 
Dart :: AudioPlayerState.Playing flutter 
Dart :: support various locales flutter 
Dart :: flutter add external icons 
Dart :: <i class="fluigicon fluigicon-map-marker icon-xl"</i 
Dart :: dart break double for loop 
Dart :: dart list join 
Dart :: flutter display alert dialog after server error 
Swift :: swift + data to string 
Swift :: uitableviewcell automatic height 
Swift :: swift ui function with return value 
Swift :: remove back button swift 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =