How to Get Device Lat Long in Flutter

Hello Guys, How Are You All ? Hope You All Are Very Well. As a Flutter developer Sometimes you need device current lattitude and Longitude. So in This tutorial we are going to learn how to get device lat long in flutter

how to get device lat long in flutter

How to Get Device Lat Long in Flutter

  • First of all. All You Need is GeoLocation package. So define on pubspec.yaml file and then get that dependencies. Same like below.
  • Now. For Android Users, you Must have to define below both line in your Flutter_project_path/android/app/src/main/AndroidManifest.xml File Exactly Like below.
  • For iOS users, You need to declare the description for the desired permission in ios/Runner/Info.plist:
  • Now, import geolocation.dart in your file where you want lat and long.
  • Define latitude and longitude that you want to use. In my case i need lat long in String Formate so i am defining String.
  • Now Create Method named _getCurrentLocation with async Like Below.
  • Now Trigger This Method where you wanna use. If users allow for location it will give you lat long
  • also you can customize accuracy: by refering its Documentation file.
  • i am giving my source code here that will help you to understand.
How to get Lat Long in flutter ?

As Flutter Developer sometimes we need device current latitude and longitude. First of all you need is GeoLocation package So that add geoLocation plugin in pubsec.yaml file and then get dependencies. As like below.

So Guys That’s it For How to Get Device Lat Long in Flutter. Comment below Your thoghts and your quries.

Also Read How to Get DeviceId in Flutter with Example Source Code

1 thought on “How to Get Device Lat Long in Flutter”

Leave a Comment

%d bloggers like this: