HEALTH 8.1.0 : plugin throwing exception when user does some workout like Multisport in iOS
When user does activity like Multisport which is not defined in the plugin's HealthWorkoutActivityType values, the plugin crashes with the below error.
Stacktrace:
*******(Flutter)[647] <Notice>: [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: No element
ListBase.firstWhere (dart:collection/list.dart:132:5)
new WorkoutHealthValue.fromJson (package:health/src/health_value_types.dart:139:42)
HealthFactory._parse.
MappedListIterable.elementAt (dart:_internal/iterable.dart:415:31)
ListIterator.moveNext (dart:_internal/iterable.dart:344:26)
new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
new List.of (dart:core-patch/array_patch.dart:47:28)
ListIterable.toList (dart:_internal/iterable.dart:214:7)
HealthFactory._parse (package:health/src/health_factory.dart:512:8)
HealthFactory._dataQuery (package:health/src/health_factory.dart:473:14)
HealthFactory._prepareQuery (package:health/src/health_factory.dart:447:12)
HealthFactory.getHealthDataFromTypes (package:health/src/health_factory.dart:416:22)
Device / Emulator and OS
- Device: iPhone 12
- OS: iOS 17
Steps to reproduce Select workout type : MultiSport from apple watch and do some activity, which will be reflected in the health app. When the plugin tries to read these workouts, it causes exception - Bad State: No element