Skip to content
Next Next commit
Add rawWorkoutActivityType to WorkoutHealthValue for native data comp…
…atibility
  • Loading branch information
klnfreedom committed Jun 24, 2025
commit 955f457bd7baf44776f76bd48c3209a824f8ca5e
7 changes: 6 additions & 1 deletion packages/health/lib/src/health_value_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,23 @@ class WorkoutHealthValue extends HealthValue {
/// Might not be available for all workouts.
HealthDataUnit? totalStepsUnit;

/// Raw workoutActivityType from native data format.
String? rawWorkoutActivityType;

WorkoutHealthValue(
{required this.workoutActivityType,
this.totalEnergyBurned,
this.totalEnergyBurnedUnit,
this.totalDistance,
this.totalDistanceUnit,
this.totalSteps,
this.totalStepsUnit});
this.totalStepsUnit,
this.rawWorkoutActivityType});

/// Create a [WorkoutHealthValue] based on a health data point from native data format.
factory WorkoutHealthValue.fromHealthDataPoint(dynamic dataPoint) =>
WorkoutHealthValue(
rawWorkoutActivityType: dataPoint['workoutActivityType'] as String?,
workoutActivityType: HealthWorkoutActivityType.values.firstWhere(
(element) => element.name == dataPoint['workoutActivityType'],
orElse: () => HealthWorkoutActivityType.OTHER,
Expand Down