Installation
Add the facade package, then complete the native setup for each platform your app supports.
Requirements
| Component | Minimum |
|---|---|
| Flutter | 3.35.7 |
| Dart | 3.9.2 |
| Android | API 26, Java 17, Kotlin 2.1 |
| iOS | iOS 15, Swift 5.9 |
Add the package
flutter pub add health_connectorImport the public facade:
import 'package:health_connector/health_connector.dart';Android Health Connect
Declare permissions
Add every health data permission your application uses to android/app/src/main/AndroidManifest.xml.
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.health.READ_STEPS" />
<uses-permission android:name="android.permission.health.WRITE_STEPS" />
<application>
<activity-alias
android:name="ViewPermissionUsageActivity"
android:exported="true"
android:targetActivity=".MainActivity"
android:permission="android.permission.START_VIEW_PERMISSION_USAGE">
<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
</intent-filter>
</activity-alias>
</application>
</manifest>Declare only what you use
Google Play reviews Health Connect access against your declared use cases. Keep the manifest and Play Console declarations aligned with actual product behavior.
Use FlutterFragmentActivity
Health Connect permission requests use the Activity Result API.
package com.example.yourapp
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity : FlutterFragmentActivity()Configure the Android build
Enable AndroidX in android/gradle.properties:
android.useAndroidX=true
android.enableJetifier=trueSet API 26 and SDK extension 19 in your app module:
android {
compileSdkExtension = 19
defaultConfig {
minSdk = 26
}
}iOS HealthKit
Open ios/Runner.xcworkspace in Xcode, set the deployment target to iOS 15 or newer, and add the HealthKit capability to the Runner target.
Add purpose strings to ios/Runner/Info.plist:
<key>NSHealthShareUsageDescription</key>
<string>Read activity and vital data to show your health history.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>Save measurements that you choose to record.</string>Purpose strings should name the data and explain the user benefit. Generic text can lead to App Store review rejection.
Verify availability
Before showing a health feature, inspect the platform status:
final status = await HealthConnector.getHealthPlatformStatus();
if (status != HealthPlatformStatus.available) {
// Hide the feature or guide the user to install/update the health service.
}Continue with Quick start once both platform targets are configured.