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