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.flutter-io.cn/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


