Skip to content
GUIDE · UNIFIED WORKFLOW

Installation

Add the facade package, then complete the native setup for each platform your app supports.

Requirements

ComponentMinimum
Flutter3.35.7
Dart3.9.2
AndroidAPI 26, Java 17, Kotlin 2.1
iOSiOS 15, Swift 5.9

Add the package

bash
flutter pub add health_connector

Import the public facade:

dart
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.

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.

kotlin
package com.example.yourapp

import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity : FlutterFragmentActivity()

Configure the Android build

Enable AndroidX in android/gradle.properties:

properties
android.useAndroidX=true
android.enableJetifier=true

Set API 26 and SDK extension 19 in your app module:

kotlin
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:

xml
<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:

dart
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.

Released under the Apache 2.0 License.