geo_fence_utils 2.1.0
geo_fence_utils: ^2.1.0 copied to clipboard
Production-ready geofence calculations. Accurate distance (Haversine), circle & polygon detection, batch operations. 96% test 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 #
- API Docs: https://pub.dev/packages/geo_fence_utils
- Test Coverage: TEST_COVERAGE.md
- Example App:
/exampledirectory - Issues: https://github.com/MEET-1008/geo_fence_utils/issues
- Discussions: https://github.com/MEET-1008/geo_fence_utils/discussions
๐งช 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:
- Fork repository
- Create feature branch
- Commit changes
- Push branch
- 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


