I wanted a button that can get the location of the user and display the place name using GPS.
I tried map_view but it only can get latitude and longitude.
Get user's latitude and longitude To query the current location of the device, simply make a call to the getCurrentPosition() method. For example: import 'package:geolocator/geolocator. dart';Position position = await Geolocator.
Get the user's locationIn your screen's dart file, import the library. import 'package:geolocator/geolocator. dart'; Create variables for storing the position and the address, in the state class.
Open AndroidManifest. xml in your code editor and add one of the following. ACCESS_FINE_LOCATION is the most precise, whereas ACCESS_COARSE_LOCATION gives results equal to about a city block. With this setup complete, you can create the widget that will trigger and display the user's current location.
use the geocoder plugin it provide you a findAddressesFromCoordinates
import 'package:geocoder/geocoder.dart';
example;
final coordinates = new Coordinates(1.10, 45.50);
addresses = await Geocoder.local.findAddressesFromCoordinates(coordinates);
first = addresses.first;
print("${first.featureName} : ${first.addressLine}");
NOTE: you can also use geolocation plugin to get a lot of useful information like Retrieving last known location
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With