Baseflow / Baseflow/flutter-geolocator
[Question]: Geolocator.getPositionStream triggers frame refreshes when used with MapLibre_gl
- Dominant language
- Dart
- Stars
- 1.3k
- Forks
- 803
- Avg merge
- 8h 16m
- Merged PRs (30d)
- 1
Description
### Please check the following before submitting a new issue.
- [x] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [x] I have carefully [read the documentation](https://github.com/baseflow/flutter-geolocator/blob/main/geolocator/README.md).
### Please select for which platform(s) you need help
- [x] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows
### Your question
Using Geolocator.getPositionStream with MapLibre_gl causes frame refreshes on Android, even when the GPS coordinates are not changing. This behavior, observed on Android but not iOS, leads to constant frame generation.
Versions:
* geolocator: 14.0.1
* maplibre_gl: 0.22.0
Sample code to reproduce the issue:
```dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:maplibre_gl/maplibre_gl.dart';
class TestGeolocator extends StatefulWidget {
const TestGeolocator({super.key});
@override
State createState() => _TestGeolocatorState();
}
class _TestGeolocatorState extends State {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
await _trackCoordinates();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: MapLibreMap(
compassViewPosition: CompassViewPosition.topRight,
styleString: 'https://style_url',
myLocationEnabled: true,
initialCameraPosition: const CameraPosition(
target: LatLng(40.947970551634754, -4.118041773948952),
zoom: 18.5,
),
trackCameraPosition: true,
),
),
);
}
Future _trackCoordinates() async {
var locationSettings = const LocationSettings(accuracy: LocationAccuracy.high, distanceFilter: 5);
Geolocator.getPositionStream(locationSettings: locationSettings).listen((position) async {
print('${position.latitude}, ${position.longitude}');
});
}
}
```
Any idea on how to prevent this?
Thanks!
### Version
14.0.1
Contributor guide
Assessment
This issue has not been assessed yet.