Installation
Add the health plugin to a Flutter app, configure it, and request permissions.
This page covers the dependency, initialization and permission requests. Platform-specific configuration is described in Android setup and iOS setup.
Add the dependency
pub.dev Local path pubspec.yaml If you use a published version instead of the local path, replace the path with the appropriate version constraint.
Initialize the plugin
Call
configure()once, before you use any other method:configure()resolves a stable device identifier and registers JSON factories. For testing, you can pass a customDeviceInfoPlugintoHealth().Request permissions when needed
Check which permissions are granted and request the missing ones:
The plugin validates each type and access combination and throws an
ArgumentErrorfor illegal combinations:- On iOS, some types support READ only.
- On Android, WRITE is not allowed for certain ECG-related event types.
See Permissions for the full permission model.
Configure each platform
- Android: declare Health Connect permissions in
AndroidManifest.xml, request activity recognition, optionally enable history and background access, and handle the Health Connect install flow. - iOS: enable the HealthKit capability and add
NSHealthShareUsageDescriptionandNSHealthUpdateUsageDescriptiontoInfo.plist.
- Android: declare Health Connect permissions in