gpslocator 0.1.2 copy "gpslocator: ^0.1.2" to clipboard
gpslocator: ^0.1.2 copied to clipboard

A new flutter plugin which gets the current device location stream ,last location and handles location permissions.

gpslocator #

A new flutter plugin for getting for location tracking

Getting Started #

Importing #


import 'package:gpslocator/GpsLocator.dart';


final GpsLocator gpsLocator = new GpsLocator();

Checking Permissions #


 await gpsLocator.checkPermission.then((permission){
      if (permission){

      //Permission is Already Granted 

      }else{

         gpsLocator.handlePermission('com.example.gpslocator_example');
     
      }
    });

Asking for permission #

         gpsLocator.handlePermission('com.example.gpslocator_example');

  This handlePermission function takes a parameter of package name and asks for 
  location permission  

Checking wheather location is active #


  await gpsLocator.isGpsActive.then((isActive)  {
          if (isActive){
              
              //location is Active
          }
           
        });

Starting Location Stream #

Location stream should be started before listening/subscribing to it

Normal
             await gpsLocator.startStream();

Configured
   
    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');

      }
        
    });


Stoping Location Stream #


 await gpsLocator.stopStream;

Getting the last location #


    await gpsLocator.lastLocation.then((lastLocation){
        //Last location  as Map
                  });

example

0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

A new flutter plugin which gets the current device location stream ,last location and handles location permissions.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

android_intent, flutter

More

Packages that depend on gpslocator