Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/health/ios/Classes/SwiftHealthPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
"date_to": Int(sample.endDate.timeIntervalSince1970 * 1000),
"source_id": sample.sourceRevision.source.bundleIdentifier,
"source_name": sample.sourceRevision.source.name,
"device_model": sample.device?.model ?? "unknown",
"recording_method": (sample.metadata?[HKMetadataKeyWasUserEntered] as? Bool == true)
? RecordingMethod.manual.rawValue
: RecordingMethod.automatic.rawValue,
Expand Down
2 changes: 2 additions & 0 deletions packages/health/lib/health.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions packages/health/lib/src/health_data_point.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class HealthDataPoint {
/// The metadata for this data point.
Map<String, dynamic>? metadata;

/// The source of the data, whether from the iPhone or Watch or something else.
/// Only available fo iOS
/// On Android: always return null
String? deviceModel;

HealthDataPoint({
required this.uuid,
required this.value,
Expand All @@ -69,6 +74,7 @@ class HealthDataPoint {
this.recordingMethod = RecordingMethod.unknown,
this.workoutSummary,
this.metadata,
this.deviceModel,
}) {
// set the value to minutes rather than the category
// returned by the native API
Expand Down Expand Up @@ -137,6 +143,7 @@ class HealthDataPoint {
: Map<String, dynamic>.from(dataPoint['metadata'] as Map);
final unit = dataTypeToUnit[dataType] ?? HealthDataUnit.UNKNOWN_UNIT;
final String? uuid = dataPoint["uuid"] as String?;
final String? deviceModel = dataPoint["device_model"] as String?;

// Set WorkoutSummary, if available.
WorkoutSummary? workoutSummary;
Expand All @@ -163,6 +170,7 @@ class HealthDataPoint {
recordingMethod: RecordingMethod.fromInt(recordingMethod),
workoutSummary: workoutSummary,
metadata: metadata,
deviceModel: deviceModel,
);
}

Expand All @@ -180,7 +188,8 @@ class HealthDataPoint {
sourceName: $sourceName
recordingMethod: $recordingMethod
workoutSummary: $workoutSummary
metadata: $metadata""";
metadata: $metadata
deviceModel: $deviceModel""";

@override
bool operator ==(Object other) =>
Expand All @@ -196,9 +205,10 @@ class HealthDataPoint {
sourceId == other.sourceId &&
sourceName == other.sourceName &&
recordingMethod == other.recordingMethod &&
metadata == other.metadata;
metadata == other.metadata &&
deviceModel == other.deviceModel;

@override
int get hashCode => Object.hash(uuid, value, unit, dateFrom, dateTo, type,
sourcePlatform, sourceDeviceId, sourceId, sourceName, metadata);
sourcePlatform, sourceDeviceId, sourceId, sourceName, metadata, deviceModel);
}