transistorsoft / flutter_background_geolocation

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection
https://www.transistorsoft.com/shop/products/flutter-background-geolocation
Other
651 stars 242 forks source link

FormatException: Invalid radix-10 number (at character 1) #1294

Closed ChrisElliotUK closed 6 months ago

ChrisElliotUK commented 6 months ago

Your Environment

• No issues found!

* Plugin config:

final bg.Config _locationConfig = bg.Config( desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH, useSignificantChangesOnly: false, pausesLocationUpdatesAutomatically: false, disableElasticity: true, isMoving: true, showsBackgroundLocationIndicator: true, allowIdenticalLocations: true, activityType: bg.Config.ACTIVITY_TYPE_FITNESS, debug: AppLogs.geolocationDebug, logLevel: AppLogs.geolocationLogLevel, stopOnStationary: false, locationTimeout: 120, stopDetectionDelay: 20, distanceFilter: 10, reset: true, locationAuthorizationRequest: "Always", );


```dart <-- Syntax highlighting: DO NOT REMOVE -->
  Future<Either<Failure, bool>> changePace() async {
    try {
      final result = await backgroundGeolocationDataSource.changePace(false);

      return Right(result);
    } catch (e) {
      print(e.toString());
      return Left(GeoLocationFailure(errorMessage: e.toString()));
    }
  }

Future<bool> changePace(bool isMoving) async =>
      await bg.BackgroundGeolocation.changePace(isMoving);

Expected Behavior

Should throw Platform excpetion with background geolocation is disabled.

Actual Behavior

has a format exception

FormatException: Invalid radix-10 number (at character 1)
BackgroundGeolocation is disabled
 ^

Steps to Reproduce

  1. Call changePace when plugin is disabled

Context

Trying to test what happens if location permission is set to denied

Debug logs

Logs ``` D/TSLocationManager( 7650): [c.t.l.a.BackgroundGeolocation removeListener] D/TSLocationManager( 7650): ✅ removeListener event: providerchange D/TSLocationManager( 7650): [c.t.l.a.BackgroundGeolocation removeListener] D/TSLocationManager( 7650): ✅ removeListener event: motionchange D/TSLocationManager( 7650): [c.t.l.a.BackgroundGeolocation removeListener] D/TSLocationManager( 7650): ✅ removeListener event: location D/TSLocationManager( 7650): [c.t.l.adapter.TSConfig e] ℹ️ Persist config, dirty: [isMoving] I/flutter ( 7650): FormatException: Invalid radix-10 number (at character 1) I/flutter ( 7650): BackgroundGeolocation is disabled I/flutter ( 7650): ^ ```
christocracy commented 6 months ago

It’s invalid to call .changePace when the plug-in is disabled.

you should be catching your exceptions

ChrisElliotUK commented 6 months ago

@christocracy I am catching it, I am just letting you know the exception that is thrown is not formatted correctly. I fully expect the error and I am just testing different scenarios. My understanding is that it should be a Platform Exception but we get FormatException

christocracy commented 6 months ago

I’ll look into it.

christocracy commented 6 months ago

I found the problem. The fix will arrive in the next version.

christocracy commented 6 months ago

Released to 4.15.3.