Hey I have tried some codes to get the full address of a coordinates.. But Iam getting error..
the code is below
import 'package:flutter/material.dart';
import 'package:geocoder/geocoder.dart';
import 'package:geolocator/geolocator.dart';
_getLocation() async {
GeolocationStatus geolocationStatus = await
Geolocator().checkGeolocationPermissionStatus();
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
debugPrint('location: ${position.latitude}');
final coordinates = new Coordinates(position.latitude, position.longitude);
debugPrint('coordinates is: $coordinates');
var addresses =
await Geocoder.local.findAddressesFromCoordinates(coordinates);
var first = addresses.first;
// print number of retured addresses
debugPrint('${addresses.length}');
// print the best address
debugPrint("${first.featureName} : ${first.addressLine}");
//print other address names
debugPrint(Country:${first.countryName} AdminArea:${first.adminArea} SubAdminArea:${first.subAdminArea}");
//print more address names
debugPrint(Locality:${first.locality}: Sublocality:${first.subLocality}");
}
In this everything is fine except the var first...When I use var first = addresses.first; It is showing error that first is not defined.. Please help me out..
question from:
https://stackoverflow.com/questions/65661350/error-in-getting-full-address-from-coordinates 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…