Get full address details based on current location's latitude and longitude in Flutter

Using Geocoder plugin you can get address from the latitiude and longitude

 import 'package:location/location.dart';
 import 'package:geocoder/geocoder.dart';
 import 'package:flutter/services.dart';

getUserLocation() async {//call this async method from whereever you need
    
      LocationData myLocation;
      String error;
      Location location = new Location();
      try {
        myLocation = await location.getLocation();
      } on PlatformException catch (e) {
        if (e.code == 'PERMISSION_DENIED') {
          error = 'please grant permission';
          print(error);
        }
        if (e.code == 'PERMISSION_DENIED_NEVER_ASK') {
          error = 'permission denied- please enable it from app settings';
          print(error);
        }
        myLocation = null;
      }
      currentLocation = myLocation;
      final coordinates = new Coordinates(
          myLocation.latitude, myLocation.longitude);
      var addresses = await Geocoder.local.findAddressesFromCoordinates(
          coordinates);
      var first = addresses.first;
      print(' ${first.locality}, ${first.adminArea},${first.subLocality}, ${first.subAdminArea},${first.addressLine}, ${first.featureName},${first.thoroughfare}, ${first.subThoroughfare}');
      return first;
    }

EDIT

Please use Geocoding instead of Geocoder as Geocoding is maintained by baseflow.com agency.


in pubspec.yaml

geolocator: '^5.1.1'
  geocoder: ^0.2.1

Import this packages

import 'package:geolocator/geolocator.dart';
import 'package:geocoder/geocoder.dart';


_getLocation() 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;
        print("${first.featureName} : ${first.addressLine}");
      }

You'll need to use a "reverse geocoding" service, such as Google's API: https://developers.google.com/maps/documentation/geocoding/start. There are others out there as well... just google for "geocoding".

Update: apparently there's a local API as well. See: https://pub.dartlang.org/packages/geocoder