A new flutter plugin for getting for location tracking
import 'package:gpslocator/GpsLocator.dart';
final GpsLocator gpsLocator = new GpsLocator();
await gpsLocator.checkPermission.then((permission){
if (permission){
//Permission is Already Granted
}else{
gpsLocator.handlePermission('com.example.gpslocator_example');
}
});
gpsLocator.handlePermission('com.example.gpslocator_example');
This handlePermission function takes a parameter of package name and asks for
location permission
await gpsLocator.isGpsActive.then((isActive) {
if (isActive){
//location is Active
}
});
Location stream should be started before listening/subscribing to it
await gpsLocator.startStream();
await gpsLocator.startStream(interval: 1000,fastestInterval: 5000,priority: GPSPriority.BALANCED_POWER_ACCURACY);
Recommended way to start the stream ( just wheather permission and location is enabled )
await gpsLocator.checkPermission.then((permission) async {
if (permission){
await gpsLocator.isGpsActive.then((isActive) async {
if (isActive){
await gpsLocator.startStream();
}
});
}else{
gpsLocator.handlePermission('com.example.gpslocator_example');
}
});
await gpsLocator.stopStream;
await gpsLocator.lastLocation.then((lastLocation){
//Last location as Map
});