Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/health/lib/src/health_value_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,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,
Expand All @@ -152,11 +155,13 @@ class WorkoutHealthValue extends HealthValue {
this.totalDistanceUnit,
this.totalSteps,
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 Expand Up @@ -197,6 +202,7 @@ class WorkoutHealthValue extends HealthValue {
@override
String toString() =>
"""$runtimeType - workoutActivityType: ${workoutActivityType.name},
rawWorkoutActivityType: $rawWorkoutActivityType,
totalEnergyBurned: $totalEnergyBurned,
totalEnergyBurnedUnit: ${totalEnergyBurnedUnit?.name},
totalDistance: $totalDistance,
Expand All @@ -207,6 +213,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 &&
Expand All @@ -218,6 +225,7 @@ class WorkoutHealthValue extends HealthValue {
@override
int get hashCode => Object.hash(
workoutActivityType,
rawWorkoutActivityType,
totalEnergyBurned,
totalEnergyBurnedUnit,
totalDistance,
Expand Down