For help getting started with Flutter, view our online documentation.
flutter_location_plugin
Flutter plugin for getting accurate locations on the Android & iOS devices.
Usage
// Get current latitude, longitude
Future<void> _getLocation() async {
Map<dynamic, dynamic> locationMap;
String result;
try {
locationMap = await GeoLocation.getLocation;
var status = locationMap["status"];
if ((status is String && status == "true") ||
(status is bool) && status) {
var lat = locationMap["latitude"];
var lng = locationMap["longitude"];
if (lat is String) {
result = "Location: ($lat, $lng)";
} else {
// lat and lng are not string, you need to check the data type and use accordingly.
// it might possible that else will be called in Android as we are getting double from it.
result = "Location: ($lat, $lng)";
}
} else {
result = locationMap["message"];
}
} on PlatformException {
result = 'Failed to get location';
}
if (!mounted) return;
setState(() {
_result = result;
});
}
Libraries
Dart
- dart:ui
- Built-in types and core primitives for a Flutter application. [...]
- dart:async
- Support for asynchronous programming, with classes such as Future and Stream. [...]
- dart:collection
- Classes and utilities that supplement the collection support in dart:core. [...]
- dart:convert
- Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
- dart:core
- Built-in types, collections, and other core functionality for every Dart program. [...]
- dart:developer
- Interact with developer tools such as the debugger and inspector. [...]
- dart:math
- Mathematical constants and functions, plus a random number generator. [...]
- dart:typed_data
- Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]
- dart:io
- File, socket, HTTP, and other I/O support for non-web applications. [...]
- dart:isolate
- Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]