59 lines
1.2 KiB
Dart
59 lines
1.2 KiB
Dart
import 'dart:io';
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
class HealthMetric {
|
|
final DateTime timestamp;
|
|
final double value;
|
|
final String unit;
|
|
|
|
const HealthMetric({
|
|
required this.timestamp,
|
|
required this.value,
|
|
required this.unit,
|
|
});
|
|
}
|
|
|
|
abstract class IHealthGateway {
|
|
Future<bool> requestPermissions();
|
|
Future<List<HealthMetric>> fetchWeightHistory({
|
|
required DateTime start,
|
|
required DateTime end,
|
|
});
|
|
Future<List<HealthMetric>> fetchWorkouts({
|
|
required DateTime start,
|
|
required DateTime end,
|
|
});
|
|
}
|
|
|
|
class PlatformHealthGateway implements IHealthGateway {
|
|
@override
|
|
Future<bool> requestPermissions() async {
|
|
if (kIsWeb || (!Platform.isAndroid && !Platform.isIOS)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@override
|
|
Future<List<HealthMetric>> fetchWeightHistory({
|
|
required DateTime start,
|
|
required DateTime end,
|
|
}) async {
|
|
if (kIsWeb || (!Platform.isAndroid && !Platform.isIOS)) {
|
|
return [];
|
|
}
|
|
return [];
|
|
}
|
|
|
|
@override
|
|
Future<List<HealthMetric>> fetchWorkouts({
|
|
required DateTime start,
|
|
required DateTime end,
|
|
}) async {
|
|
if (kIsWeb || (!Platform.isAndroid && !Platform.isIOS)) {
|
|
return [];
|
|
}
|
|
return [];
|
|
}
|
|
}
|