Skip to content

OmkarSsawant/gpslocator

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published