From 955f457bd7baf44776f76bd48c3209a824f8ca5e Mon Sep 17 00:00:00 2001 From: klnfreedom Date: Tue, 24 Jun 2025 19:24:07 +0300 Subject: [PATCH 1/2] Add rawWorkoutActivityType to WorkoutHealthValue for native data compatibility --- packages/health/lib/src/health_value_types.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/health/lib/src/health_value_types.dart b/packages/health/lib/src/health_value_types.dart index 6a8b28819..f128f7711 100644 --- a/packages/health/lib/src/health_value_types.dart +++ b/packages/health/lib/src/health_value_types.dart @@ -140,6 +140,9 @@ 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, @@ -147,11 +150,13 @@ class WorkoutHealthValue extends HealthValue { 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, From 212dd3e41390d0480b401b6700d09c59b0af509b Mon Sep 17 00:00:00 2001 From: klnfreedom Date: Tue, 1 Jul 2025 10:41:36 +0300 Subject: [PATCH 2/2] Add rawWorkoutActivityType to WorkoutHealthValue for improved data representation --- packages/health/lib/src/health_value_types.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/health/lib/src/health_value_types.dart b/packages/health/lib/src/health_value_types.dart index f128f7711..2f4822145 100644 --- a/packages/health/lib/src/health_value_types.dart +++ b/packages/health/lib/src/health_value_types.dart @@ -193,6 +193,7 @@ class WorkoutHealthValue extends HealthValue { @override String toString() => """$runtimeType - workoutActivityType: ${workoutActivityType.name}, + rawWorkoutActivityType: $rawWorkoutActivityType, totalEnergyBurned: $totalEnergyBurned, totalEnergyBurnedUnit: ${totalEnergyBurnedUnit?.name}, totalDistance: $totalDistance, @@ -203,6 +204,7 @@ class WorkoutHealthValue extends HealthValue { @override bool operator ==(Object other) => other is WorkoutHealthValue && + rawWorkoutActivityType == other.rawWorkoutActivityType && workoutActivityType == other.workoutActivityType && totalEnergyBurned == other.totalEnergyBurned && totalEnergyBurnedUnit == other.totalEnergyBurnedUnit && @@ -214,6 +216,7 @@ class WorkoutHealthValue extends HealthValue { @override int get hashCode => Object.hash( workoutActivityType, + rawWorkoutActivityType, totalEnergyBurned, totalEnergyBurnedUnit, totalDistance,