Apple Health (iOS)
Access health data on iOS devices through Apple’s native HealthKit framework
The Flutter Health Plugin is a cross-platform solution for accessing health and fitness data in your Flutter apps. It provides a unified API that works seamlessly with:
Apple Health (iOS)
Access health data on iOS devices through Apple’s native HealthKit framework
Google Health Connect (Android)
Read and write health data on Android using Google Health Connect
Fitness Apps
Track workouts, steps, calories, and activity levels
Health Monitoring
Monitor vital signs like heart rate, blood pressure, and oxygen levels
Wellness Apps
Track sleep, mindfulness, water intake, and daily activities
Medical Apps
Record blood glucose, medications, symptoms, and health measurements
Flexible Data Queries
// Get last 24 hours of step datafinal data = await health.getHealthDataFromTypes( types: [HealthDataType.STEPS], startDate: yesterday, endDate: now,);Easy Data Recording
// Save weight measurementawait health.writeHealthData( value: 70.5, type: HealthDataType.WEIGHT, startTime: DateTime.now(),);Permission Management
// Request read accessfinal granted = await health.requestAuthorization( [HealthDataType.STEPS], permissions: [HealthDataAccess.READ],);Setup Your Project
Add the plugin to your pubspec.yaml and configure platform-specific settings
Request Permissions
Ask users for permission to access specific health data types
Read or Write Data
Use the Health API to read existing data or write new measurements
Here’s a complete example to get you started:
import 'package:health/health.dart';
// 1. Create Health instancefinal health = Health();await health.configure();
// 2. Request permissionsfinal types = [HealthDataType.STEPS];final granted = await health.requestAuthorization(types);
if (granted) { // 3. Read today's steps final now = DateTime.now(); final midnight = DateTime(now.year, now.month, now.day); final steps = await health.getTotalStepsInInterval(midnight, now);
print('Steps today: ${steps ?? 0}');}The plugin supports over 100 health data types including:
Activity
Steps, distance, calories, workouts, flights climbed
Body Measurements
Weight, height, BMI, body fat %, lean mass
Vital Signs
Heart rate, blood pressure, blood oxygen, temperature
Nutrition
Meals, water, calories, macros, micronutrients
Sleep
Sleep stages, in bed time, asleep time, REM, deep sleep
Reproductive
Menstruation flow, cycle tracking
Before using the plugin, you need to configure each platform: