diff --git a/packages/health/CHANGELOG.md b/packages/health/CHANGELOG.md index d988ea7d1..704d1cd24 100644 --- a/packages/health/CHANGELOG.md +++ b/packages/health/CHANGELOG.md @@ -1,3 +1,8 @@ +## 12.0.1 + +* Update of API and README doc +* Fix [#1118](https://github.com/cph-cachet/flutter-plugins/issues/1118) + ## 12.0.0 * **BREAKING** This release introduces a significant architectural change to the `health` plugin by removing the `singleton` pattern. diff --git a/packages/health/README.md b/packages/health/README.md index eea60737c..ffa41fc89 100644 --- a/packages/health/README.md +++ b/packages/health/README.md @@ -146,12 +146,16 @@ android.useAndroidX=true See the example app for detailed examples of how to use the Health API. -The Health plugin is used via the `Health()` singleton using the different methods for handling permissions and getting and adding data to Apple Health or Google Health Connect. +A instance of the Health plugin is create using the `Health()` constructor and is subsequently configured calling the `configure` method. Once configured, the plugin can be used for handling permissions and getting and adding data to Apple Health or Google Health Connect. Below is a simplified flow of how to use the plugin. ```dart + + // Global Health instance + final health = Health(); + // configure the health plugin before use. - Health().configure(); + await health.configure(); // define the types to get @@ -161,12 +165,12 @@ Below is a simplified flow of how to use the plugin. ]; // requesting access to the data types before reading them - bool requested = await Health().requestAuthorization(types); + bool requested = await health.requestAuthorization(types); var now = DateTime.now(); // fetch health data from the last 24 hours - List healthData = await Health().getHealthDataFromTypes( + List healthData = await health.getHealthDataFromTypes( now.subtract(Duration(days: 1)), now, types); // request permissions to write steps and blood glucose @@ -175,20 +179,20 @@ Below is a simplified flow of how to use the plugin. HealthDataAccess.READ_WRITE, HealthDataAccess.READ_WRITE ]; - await Health().requestAuthorization(types, permissions: permissions); + await health.requestAuthorization(types, permissions: permissions); // write steps and blood glucose - bool success = await Health().writeHealthData(10, HealthDataType.STEPS, now, now); - success = await Health().writeHealthData(3.1, HealthDataType.BLOOD_GLUCOSE, now, now); + bool success = await health.writeHealthData(10, HealthDataType.STEPS, now, now); + success = await health.writeHealthData(3.1, HealthDataType.BLOOD_GLUCOSE, now, now); // you can also specify the recording method to store in the metadata (default is RecordingMethod.automatic) // on iOS only `RecordingMethod.automatic` and `RecordingMethod.manual` are supported // Android additionally supports `RecordingMethod.active` and `RecordingMethod.unknown` - success &= await Health().writeHealthData(10, HealthDataType.STEPS, now, now, recordingMethod: RecordingMethod.manual); + success &= await health.writeHealthData(10, HealthDataType.STEPS, now, now, recordingMethod: RecordingMethod.manual); // get the number of steps for today var midnight = DateTime(now.year, now.month, now.day); - int? steps = await Health().getTotalStepsInInterval(midnight, now); + int? steps = await health.getTotalStepsInInterval(midnight, now); ``` ### Health Data @@ -266,7 +270,7 @@ Google Health Connect and Apple HealthKit both provide ways to distinguish sampl As such, when fetching data you have the option to filter the fetched data by recording method as such: ```dart -List healthData = await Health().getHealthDataFromTypes( +List healthData = await health.getHealthDataFromTypes( types: types, startTime: yesterday, endTime: now, @@ -294,7 +298,7 @@ If you have a list of data points, duplicates can be removed with: ```dart List points = ...; -points = Health().removeDuplicates(points); +points = health.removeDuplicates(points); ``` ## Data Types diff --git a/packages/health/lib/health.json.dart b/packages/health/lib/health.json.dart index 2162869da..4694720ea 100644 --- a/packages/health/lib/health.json.dart +++ b/packages/health/lib/health.json.dart @@ -19,6 +19,11 @@ void _registerFromJsonFunctions() { ElectrocardiogramHealthValue(voltageValues: []), ElectrocardiogramVoltageValue(voltage: 12, timeSinceSampleStart: 0), NutritionHealthValue(), + MenstruationFlowHealthValue(flow: null, dateTime: DateTime.now()), + InsulinDeliveryHealthValue( + units: 0.0, + reason: InsulinDeliveryReason.NOT_SET, + ), ]); _fromJsonFunctionsRegistered = true; diff --git a/packages/health/pubspec.yaml b/packages/health/pubspec.yaml index 3fb67cdc1..ed206e548 100644 --- a/packages/health/pubspec.yaml +++ b/packages/health/pubspec.yaml @@ -1,6 +1,6 @@ name: health description: Wrapper for Apple's HealthKit on iOS and Google's Health Connect on Android. -version: 12.0.0 +version: 12.0.1 homepage: https://github.com/cph-cachet/flutter-plugins/tree/master/packages/health environment: