Geek Culture
Published in

Geek Culture

Get Current Location Flutter Using Location Manager | Simplified

Photo by Element5 Digital on Unsplash

Hi,

This is me, we gonna look at how to get location from the device Android, Ios and Web as well.

It's quite straight forward by using the following flutter dependency.

Following the above documentation, we can get set up permissions, enable location in the device and get the current location as well.

So what I did something new here is create a manager class that still does the same thing but in an efficient manner in the coolest way.

Photo by Josh Rakower on Unsplash

Before start, I’m from the android kotlin platform so I used the same architecture we follow in android development.

Firstly, Implement the location dependency inside pubspec.yml

dependencies:
location: ^3.0.0

Then,

Create a state for location.

And

the LocationManger would be,

That's would do the work :).

Finnaly,

Everywhere you want just call like below,

Here we go the simplest way to get the current location anywhere from screens.

Any suggestions are welcome.

Thank you for reading ;)

Reference

https://www.youtube.com/

https://www.google.com/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store