geo_fence_utils 2.1.0 copy "geo_fence_utils: ^2.1.0" to clipboard
geo_fence_utils: ^2.1.0 copied to clipboard

Production-ready geofence calculations. Accurate distance (Haversine), circle & polygon detection, batch operations. 96% test coverage.

geo_fence_utils #

A production-ready Dart package for geofence calculations

Pub Version License Dart Tests Coverage


What is geo_fence_utils? #

geo_fence_utils is a comprehensive Flutter/Dart package designed for handling geofence calculations and location-based operations.

It provides utilities for:

  • Calculating distances between geographic points
  • Detecting whether points lie within circular or polygonal boundaries
  • Performing batch operations on multiple locations efficiently

This package is ideal for developers building location-aware applications without dealing with complex geographic calculations.


๐Ÿ“ธ Screenshots #

Circle Geofence Polygon Geofence Custom Markers

๐ŸŽฏ Purpose #

The primary purpose of this package is to simplify geospatial calculations in Flutter and Dart applications.

It handles complex geographic math so you can focus on building your application logic.


๐Ÿš€ Common Use Cases #

  • Delivery & Logistics โ€“ Determine if delivery addresses fall within service areas
  • Location-Based Notifications โ€“ Trigger alerts when users enter or exit zones
  • Asset Tracking โ€“ Monitor vehicles or equipment within boundaries
  • Gaming โ€“ Create location-based game zones
  • Security Systems โ€“ Detect devices leaving authorized areas
  • Attendance Systems โ€“ Check if users are inside allowed locations
  • Ride Sharing โ€“ Match drivers with passengers within radius
  • Marketing โ€“ Send location-based promotions

โœจ Key Features #

Feature Description
๐Ÿ“ Accurate Distance Calculation Uses Haversine formula (~0.5% accuracy)
๐Ÿ”ต Circle Geofence Efficient point-in-circle detection
๐Ÿ”บ Polygon Geofence Ray casting algorithm for complex shapes
โšก Batch Operations Process many points efficiently
๐Ÿ—บ Map Widgets Works with Flutter Map and Google Maps
๐Ÿ“ Custom Markers Support PNG and SVG markers
๐ŸŒ Cross Platform Works on iOS, Android, Web, Desktop
๐Ÿงช Well Tested 266 tests with 96% coverage
๐Ÿงฉ Pure Dart No native dependencies
๐Ÿ”’ Type Safe Full null safety support

๐Ÿ“ฆ Installation #

Add the package to your pubspec.yaml:

dependencies:
  geo_fence_utils: ^2.1.0

Then run:

flutter pub get

Or use Flutter CLI:

flutter pub add geo_fence_utils

๐Ÿ“š Documentation #

Full usage examples are available in the example app.

โžก See example usage here:

example/README.md

The example demonstrates:

  • Creating geofence circles
  • Creating polygon boundaries
  • Drawing polylines
  • Adding custom markers
  • Displaying geofences on maps
  • Running geofence detection logic

๐Ÿงฉ Package Overview #

Core Models #

The package provides three main data models:

  • GeoPoint โ€“ Represents a geographic coordinate
  • GeoCircle โ€“ Circular geofence with center and radius
  • GeoPolygon โ€“ Polygon geofence with multiple vertices

Services #

Three main service classes handle operations:

  • GeoDistanceService

    • Calculate distance between points
    • Find closest or farthest point
  • GeoCircleService

    • Check points inside circles
    • Detect circle overlap
  • GeoPolygonService

    • Point inside polygon
    • Polygon area and perimeter

Map Widgets #

Interactive widgets for visualizing geofences:

  • GeoGeofenceMap โ€“ Main map widget
  • GeoCircleWidget โ€“ Circular geofence display
  • GeoPolygonWidget โ€“ Polygon geofence display
  • GeoPolylineWidget โ€“ Route and path display
  • GeoMarkerWidget โ€“ Custom markers (PNG/SVG)

โš™ Technical Details #

  • Coordinate System: WGS 84 (GPS standard)

  • Distance Formula: Haversine

  • Distance Units: Meters

  • Supported Platforms:

    • iOS
    • Android
    • Web
    • Windows
    • macOS
    • Linux

โšก Performance #

Operation Time Complexity Notes
Distance calculation O(1) Constant time
Circle containment O(1) Constant time
Polygon containment O(n) Linear with vertices
Batch filtering O(nร—m) n points, m vertices

๐Ÿ“š Documentation & Resources #


๐Ÿงช Testing #

Run tests:

flutter test

Generate coverage report:

flutter test --coverage
genhtml coverage/lcov.info -o coverage/html

๐Ÿค Contributing #

Contributions are welcome.

Please ensure:

  • All tests pass
  • Code follows Dart style guidelines
  • New features include tests
  • Documentation updated

Steps:

  1. Fork repository
  2. Create feature branch
  3. Commit changes
  4. Push branch
  5. Open Pull Request

๐Ÿ“„ License #

This project is licensed under the MIT License.

See the LICENSE file for details.


Built with โค๏ธ for the Flutter/Dart community

7
likes
140
points
222
downloads

Publisher

verified publishermnbtechhube.com

Weekly Downloads

Production-ready geofence calculations. Accurate distance (Haversine), circle & polygon detection, batch operations. 96% test coverage.

Repository (GitHub)
View/report issues

Topics

#geography #geolocation #geofencing #maps #distance

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, flutter_map, google_maps_flutter, latlong2

More

Packages that depend on geo_fence_utils