Reputation: 21
i am developing an application that will hit an api containing user position from geolocator in background using flutter_background_service but sometimes this error occur and the service wont work.
This is my onStart in main.dart
@pragma('vm:entry-point')
void onStart(ServiceInstance service) async {
service.on("stop").listen((event) {
service.stopSelf();
});
service.on("start").listen((event) {});
Timer.periodic(const Duration(minutes: 15), (timer) async {
final currentLocation = await Geolocator.getLastKnownPosition(
forceAndroidLocationManager: true);
final id = await CommonUtils.readFromSecureStorage(
key: CommonConstants.attendanceId);
await DioClient().post(endpoint: url, body: requestBody);
});
}
Upvotes: 1
Views: 51