Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

A Stable GeoFence Library

A Stable LibraryLibrary for GeoFence

A flutter project to provide Geo Fence functionality in Android and IOS

Getting Started

Getting Started

Android

In your AndroidManifest.xml you should add the following lines:

final geoFenceService = GeoFenceService()

Starting GeoFenceService

geoFenceService.startService({
    ///Latitude of the fence center
    fenceCenterLatitude: _fence_latitude,

    ///Longitude of the fence center
    fenceCenterLongitude: _fence_longitude,
    
    ///Radius in meter which indicates how much area will be covered by Fence
    radius: fence_area,
})

Stop GeoFenceService

geoFenceService.stopFenceService()

Get User status with respect to Fence

Status status = geoFenceService.getStatus()

Get user’s current location

Position? position = geoFenceService.getCurrentLocation()

Listen to change for enter and Exit status for the fence

geoFenceService.geoFenceStatusListener.listen((geoFenceStatus) => {
    ///here geoFenceStatus will be listened whenever user enters or exit
})

Important: As the geoFenceStatusListener is a stream so do not forget to cancel it when the widget gets dispose().

Note: This library doesn’t work when the app is in the background.

Reference: This library uses GeoLocator internally

Download and Contribute to this library source code at given GitHub

Exit mobile version