bg.BackgroundGeolocation.setOdometer error
Your Environment
- Plugin version:current version
- Platform: iOS or Android: Android
- OS version:
- Device manufacturer / model:Samsung galaxy S23 Ultta
- Flutter info (
flutter doctor): - Plugin config:
bg.BackgroundGeolocation.setOdometer(0.0);
Expected Behavior
To reset the odometer value
Actual Behavior
generates the error and does nothing
Steps to Reproduce
1.After of this line bg.BackgroundGeolocation.setOdometer(0.0); the the program jumps to the page message_codecs.dart to this line: throw PlatformException(code: errorCode, message: errorMessage as String?, details: errorDetails, stacktrace: errorStacktrace);
2. After of debug and run the next line jumps to platform_channel.dart page and it stop in this line:final Map<dynamic, dynamic>? result = await invokeMethod<Map<dynamic, dynamic>>(method, arguments);
3. After it jumps to bacakground_geolocation.dart page and stop in the below code:
static Future
Context
only debug the program
Debug logs
Logs
PASTE_YOUR_LOGS_HERE
setOdometer returns a Promise. Catch the error.
How i can to do this? of this way? bg.BackgroundGeolocation.setOdometer(1234.56).then((laglng) { print('[setOdometer] success: '); });
That's not catching your error.
https://dart.dev/codelabs/async-await
I have this code to get the error; bg.BackgroundGeolocation.setOdometer(0.0).then((value) { print(value); // }).catchError((error) { print('error: $error'); }); So after of run this code, this return this error: I/flutter (27320): error: PlatformException(1, null, null, null) How can fix it?

Christ, but how i can fix this? In the below code do i need to put a vale with latitude and longitude? based in the basic example of your demo, where in the code can I place this setOdometer function? maybe after the start function or at some special time? bg.BackgroundGeolocation.setOdometer(0.0).then((value) { print(value); // }).catchError((error) { print('error: $error'); });
Do you know what "location permission denied" means?
Have you read what the api docs for .setOdometer say?
- Yes, "location permission denied" is when the user not accept location permissions, but this is not the case because it has them enabled.
- Yes i read the docs for .setOdometer , i see this link but is very short the documentation: https://pub.dev/documentation/flutter_background_geolocation/latest/flt_background_geolocation/BackgroundGeolocation/setOdometer.html. Only tell me please which requirements do i need to set to run .setOdometer or where can i to find more documentation with more examples?
As the api docs say, setOdometer is basically the same as calling .getCurrentPosition.
You think you have location permission, but you do not.
Thank you very much by your help. Excellent!!!
Hello, is the odometer value that the plugin has by default in meters? If, for example, I want to pass this value to kilometers, should I multiply this value by 1000? And on the contrary, if a vehicle, for example, has traveled 10 thousand kilometers, should I divide 10,000/1000 thousand to convert it to meters?
is the odometer value that the plugin has by default in meters?
Yes.
I want to pass this value to kilometers, should I multiply this value by 1000?
What do you think? The prefix "kilo" means thousand.
- kilometer = 1000 meters.
- kilogram = 1000 grams
- kilowatt = 1000 watts.
- kilobyte = 1024 bytes.