The main aim of this package is to ease the development process when the current place name is to be taken.
Features
This package can do the following
- Get the user location access.
- Get the name of the location with the coordinates.
- Provide  human-understandable error messages.
Getting started
Import the package and follow the instructions in the Usage section.
Usage
For example, you need to get the location name; below are the steps to be followed..
- Create an object for the
LocationNameClassfinal LocationName locationName = LocationName(); - Call the
getLocationPermission()function that gives a future and then chain it togetAddress()function which gives the place name.
locationName.getLocationPermission().then((dataMap) {
if (dataMap["hasError"]) {
ScaffoldMessenger.of(context).showSnackBar(
sb5Sec(textContent: Text(dataMap["eMsg"].toString())));
} else {
locationName
.getAddress(
lat: dataMap["data"]["latitude"],
lon: dataMap["data"]["longitude"])
.then((addressMap) {
locationTEC.text = addressMap["data"];
});
}
});
In the above exaple the addressMap["data"] extracts data in the below format
"Chennai, Tamil Nadu, India"
Functions available
The LocationName Class contains he below functions
getLocationPermission(): Future responsible for handeling permission -hasError: This flag denotes that there is an issue with the api called
- `eMsg` : The actual error message
getAddress(): Future responsible for retriving location name -hasError: This flag denotes that there is an issue with the api called
- `eMsg` : The actual error message
- `data` : If `hasError` is set to `false`, this field contaings the place name. This field is an abstract of the class `Placemark`
Next Goals:
To expose thePlacemark- Users can build the name with the meta data.
To implement stream of place name- This allows a stream of name when location changes
Now that the possibilities are endless. Play with this package. :grinning:
Libraries
- location_name
- Support for doing something awesome.