fromArgument function

Object? fromArgument(
  1. HealthkitResource resource,
  2. String argument
)

Implementation

Object? fromArgument(HealthkitResource resource, String argument) {
  switch (resource) {
    case HealthkitResource.activity:
      return (jsonDecode(argument) as List)
          .map((e) => ActivitySummary.fromJson(e))
          .toList();
    case HealthkitResource.profile:
      return ProfileSummary.fromJson(jsonDecode(argument));
    case HealthkitResource.body:
      return BodySummary.fromJson(jsonDecode(argument));
    case HealthkitResource.sleep:
      return (jsonDecode(argument) as List)
          .map((e) => SleepSummary.fromJson(e))
          .toList();
    case HealthkitResource.workout:
      return (jsonDecode(argument) as List)
          .map((e) => WorkoutSummary.fromJson(e))
          .toList();
    case HealthkitResource.glucose:
      return (jsonDecode(argument) as List)
          .map((e) => QuantitySample.fromJson(e))
          .toList();
    case HealthkitResource.bloodPressure:
      return (jsonDecode(argument) as List)
          .map((e) => BloodPressureSample.fromJson(e))
          .toList();
    case HealthkitResource.heartRate:
      return (jsonDecode(argument) as List)
          .map((e) => QuantitySample.fromJson(e))
          .toList();
    default:
      return null;
  }
}