Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HealthKitReporter.workoutRouteQuery: Unhandled Exception: type 'Null' is not a subtype of type 'List<dynamic>' #38

Closed
mpillawa opened this issue Apr 10, 2022 · 6 comments

Comments

@mpillawa
Copy link

mpillawa commented Apr 10, 2022

Describe the bug
Hi,
I am trying to read route data from Health App tracked with an Apple Watch. The route is correctly displayed in Health App. When trying to read the route data, I get following Exceptions:

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'List'
new WorkoutRoute.fromJson
package:health_kit_reporter/…/payload/workout_route.dart:30
HealthKitReporter.workoutRouteQuery.
package:health_kit_reporter/health_kit_reporter.dart:155
_rootRunUnary (dart:async[/zone.dart:1434:47])
_CustomZone.runUnary (dart:async[/zone.dart:1335:19])
_CustomZone.runUnaryGuarded (dart:async[/zone.dart:1244:7])
_BufferingStreamSubscription._sendData (dart:async[/stream_impl.dart:341:11])
_DelayedData.perform (dart:async[/stream_impl.dart:591:14])
_StreamImplEvents.handleNext (dart:async[/stream_impl.dart:706:11])
_PendingEvents.schedule. (dart:async[/stream_impl.dart:663:7])
_rootRun (dart:async[/zone.dart:1418:47])
_CustomZone.run (dart:async[/zone.dart:1328:19])
_CustomZone.runGuarded (dart:async[/zone.dart:1236:7])
_CustomZone.bindCallbackGuarded. (dart:async[/zone.dart:1276:23])
_rootRun (dart:async[/zone.dart:1426:13])
_CustomZone.run (dart:async[/zone.dart:1328:19])
_CustomZone.runGuarded (dart:async[/zone.dart:1236:7])
_CustomZone.bindCallbackGuarded. (dart:async[/zone.dart:1276:23])
_microtaskLoop (dart:async[/schedule_microtask.dart:40:21])
_startMicrotaskLoop (dart:async[/schedule_microtask.dart:49:5])

To Reproduce
Here are my code fragments to read the data:

void _startUpdateStreams() async {
List identifierList = [SeriesType.route.identifier];

Predicate _timeIntervallPredicate = Predicate(
DateTime.now().add(const Duration(days: -7)),
DateTime.now().add(const Duration(days: 7)));

_workoutRouteUpdates(_timeIntervallPredicate);

for (int i = 0; i < identifierList.length; i++) {
final isSet = await HealthKitReporter.enableBackgroundDelivery(
identifierList[i], UpdateFrequency.immediate);
log.d('enableBackgroundDelivery for '+identifierList[i]+': $isSet');
}
}

void _workoutRouteUpdates(Predicate _predicate) {
final sub =
HealthKitReporter.workoutRouteQuery(_predicate, onUpdate: (serie) {
log.d('Updates for workoutRouteQuery');
log.d("serie.locations.length: " + serie.locations.length.toString());
});
log.d('workoutRouteQuery: $sub');
}

Expected behavior
Do not get an exception but get access to the location data.

Smartphone (please complete the following information):

  • Device: iPhone7
  • OS: iOS15.4.1
@kvs-coder
Copy link
Owner

Hi @mpillawa

Thank you for your report, unfortunately there is a lack of the api for workout routes, I will introduce it in the next closest release ASAP

@mpillawa
Copy link
Author

Hi @VictorKachalov,

thank you for your quick reply. I am very excited about your plugin and look forward to the future extension to read route data. If you are interested, I will be happy to assist with testing early releases.

@kvs-coder
Copy link
Owner

kvs-coder commented Apr 17, 2022

Hi @mpillawa

I am happy to announce, that the version 2.0.1 is submitted. It supports workout route queries. It might introduce a breaking change, as I removed the stream event handler for this query and the data is a ready date which is already saved in HealthKit. This allowed me to read all the route and location batches at one time, by providing a predicate.

@mpillawa
Copy link
Author

Hi @VictorKachalov,

I tried the 2.0.1 update, but without success. After changing the code to workoutRouteQuery, I still get the exception:

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List'
HealthKitReporter.workoutRouteQuery
package:health_kit_reporter/health_kit_reporter.dart:333

workoutRouteQuery

This is my code to call workoutRouteQuery. Obviously no magic inside:

Predicate _timeIntervallPredicate = Predicate(
DateTime.now().add(const Duration(days: -7)),
DateTime.now().add(const Duration(days: 7)));
List woRouteList =
await HealthKitReporter.workoutRouteQuery(_predicate);

Thanks for your support!

@kvs-coder
Copy link
Owner

@mpillawa have you tried to run pod update? This new version consumes the original HealthKitReporter, which also introduces new code related to workout rout query

@mpillawa
Copy link
Author

mpillawa commented May 2, 2022

@VictorKachalov yes, after pod update I got the route data. Thank you very much !!!

@mpillawa mpillawa closed this as completed May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants