Skip to main content
RapidDev - Software Development Agency
flutterflow-integrationsCustom Action (Dart)

Google Fit

Connecting FlutterFlow to Google Fit means using Android's Health Connect, not a REST API — Google deprecated the Google Fit REST API in 2024. The modern path is a Custom Action (Dart) wrapping the `health` pub.dev package, which reads Health Connect data on-device using the same package you use for HealthKit. This works on Android only, requires Health Connect permission declarations in AndroidManifest.xml, and must be tested on a real Android device.

What you'll learn

  • Why the Google Fit REST API is deprecated (2024) and why Health Connect is the correct modern path
  • How to use the same `health` pub.dev package for both Android Health Connect and iOS HealthKit
  • How to write a Custom Action that requests Health Connect permissions and reads activity data
  • How to add Health Connect permission declarations to AndroidManifest.xml in the exported project
  • How to guard your action with Platform.isAndroid and test on a real Android device
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate15 min read2-3 hoursHealth & FitnessLast updated July 2026RapidDev Engineering Team
TL;DR

Connecting FlutterFlow to Google Fit means using Android's Health Connect, not a REST API — Google deprecated the Google Fit REST API in 2024. The modern path is a Custom Action (Dart) wrapping the `health` pub.dev package, which reads Health Connect data on-device using the same package you use for HealthKit. This works on Android only, requires Health Connect permission declarations in AndroidManifest.xml, and must be tested on a real Android device.

Quick facts about this guide
FactValue
ToolGoogle Fit
CategoryHealth & Fitness
MethodCustom Action (Dart)
DifficultyIntermediate
Time required2-3 hours
Last updatedJuly 2026

The Google Fit REST API Is Deprecated — Here Is the Modern Path

If you search for 'FlutterFlow Google Fit' today, most results still point to the Google Fitness REST API at googleapis.com/fitness. Do not build against it. Google announced the deprecation of the Google Fit REST API in 2024, with existing access limited and no new features being added. For Android health data in a new FlutterFlow app, the correct path is Health Connect — the on-device health data store that Android 14+ ships with built in (and older versions can install from the Play Store).

The good news for FlutterFlow developers is that Health Connect uses the same `health` pub.dev package that reads HealthKit on iOS. You write one Custom Action, guard it with `Platform.isAndroid`, and point it at Health Connect's permission model instead of HealthKit's. The data types (steps, heart rate, sleep, active calories) are nearly identical between the two platforms, and the authorization flow follows the same pattern: show a permission dialog, read authorized data for a date range, return it as a JSON string to App State.

The key differences from the iOS HealthKit path: on Android, Health Connect permissions are declared in `AndroidManifest.xml` rather than `Info.plist`, and the Health Connect app must be installed on the user's device (it is built in on Android 14+, but needs a separate install on Android 9-13). The `health` package handles these differences internally — your Dart code looks nearly identical between platforms. As with HealthKit, this Custom Action does not work in FlutterFlow's web preview; test on a real Android device.

Integration method

Custom Action (Dart)

Google deprecated the Google Fit REST API in 2024, ending long-term support for new integrations against `googleapis.com/fitness`. The modern path for Android fitness data in FlutterFlow is Health Connect — the on-device health data store that replaced Google Fit. You access it through a Custom Action wrapping the `health` pub.dev package, the same package used for HealthKit on iOS. The action requests Health Connect permissions, reads steps, heart rate, sleep, and other data types from the on-device store, and returns the data to App State. No network calls are made and no API keys are needed. If you genuinely need the legacy Google Fit REST API for existing data, a separate API Group proxied through a Cloud Function (holding the Google OAuth client secret) is required, but this is a transitional path before the API shuts down.

Prerequisites

  • FlutterFlow account on a paid plan (Basic or higher) for code export or GitHub integration
  • Android device running Android 9 or later with Health Connect installed (built in on Android 14+)
  • FlutterFlow project configured for Android builds
  • Basic familiarity with FlutterFlow's Custom Code panel for adding packages and writing Dart
  • Android Studio or ability to edit AndroidManifest.xml in the exported project (required for Health Connect permission declarations)

Step-by-step guide

1

Add the `health` package to Pubspec Dependencies

In your FlutterFlow project, click Custom Code in the left navigation panel. At the top of the Custom Code screen you will see a Pubspec Dependencies section — this is where you add pub.dev packages without using any terminal commands. Click + to add a new dependency and type `health` in the name field. Check pub.dev/packages/health for the current stable version and enter that exact version number (for example, `health: ^12.0.0`). Click Save. FlutterFlow will download and link the package in the background — you do not need to run `flutter pub get` manually. The `health` package is a unified cross-platform wrapper: it reads from HealthKit on iOS and from Health Connect on Android. By adding a single package, you enable health data access on both platforms. If you only need Android support, the same package still works — you will simply guard your action with `Platform.isAndroid` to prevent the iOS HealthKit code path from running. Once saved, the package is available to import in your Custom Actions.

Pro tip: Pin an exact version rather than a caret range in Pubspec Dependencies — the `health` package has had breaking API changes between major versions, and pinning protects your production app from unexpected updates.

Expected result: The `health` package appears in your Pubspec Dependencies list and the FlutterFlow project builds without dependency conflict errors.

2

Write the getHealthConnectData Custom Action

In Custom Code, click + Add → Action and name it `getHealthConnectData`. This action requests Health Connect permissions and reads activity data for a given date range. Start by setting the return type to String and adding two DateTime arguments: `startDate` and `endDate`. In the Dart editor, import the required packages at the top: `import 'package:health/health.dart';`, `import 'dart:io' show Platform;`, and `import 'dart:convert';`. Inside the action body, add a platform guard at the top: `if (!Platform.isAndroid) return '[]';` — Health Connect is Android-only, and without this guard the action would throw on iOS or web. Create a `Health()` instance, call `health.configure(useHealthConnectIfAvailable: true)` to enable the Health Connect provider on Android. Define a list of health types you want to read — for example `[HealthDataType.STEPS, HealthDataType.HEART_RATE, HealthDataType.SLEEP_ASLEEP, HealthDataType.ACTIVE_ENERGY_BURNED]`. Call `await health.requestAuthorization(types)` — this triggers the Health Connect permission sheet on Android. Check the boolean result — if the user denied access, return `'[]'`. If authorized, call `await health.getHealthDataFromTypes(startDate: startDate, endDate: endDate, types: types)` to read the data. Convert the resulting `List<HealthDataPoint>` to a JSON-encodable list of maps and return `jsonEncode(result)`. Click Save in the Custom Code panel. In the Arguments configuration below the editor, verify that `startDate` and `endDate` are defined as DateTime parameters and the return type is String.

custom_action.dart
1// custom_action.dart — getHealthConnectData
2import 'package:flutter/material.dart';
3import 'package:health/health.dart';
4import 'dart:io' show Platform;
5import 'dart:convert';
6
7Future<String> getHealthConnectData(
8 DateTime startDate,
9 DateTime endDate,
10) async {
11 // Health Connect is Android-only
12 if (!Platform.isAndroid) return '[]';
13
14 final health = Health();
15 // Enable Health Connect provider on Android
16 health.configure(useHealthConnectIfAvailable: true);
17
18 final types = [
19 HealthDataType.STEPS,
20 HealthDataType.HEART_RATE,
21 HealthDataType.SLEEP_ASLEEP,
22 HealthDataType.ACTIVE_ENERGY_BURNED,
23 ];
24
25 // Request Health Connect permission sheet
26 final authorized = await health.requestAuthorization(types);
27 if (!authorized) return '[]';
28
29 // Read data for the given date range
30 final dataPoints = await health.getHealthDataFromTypes(
31 startDate: startDate,
32 endDate: endDate,
33 types: types,
34 );
35
36 // Convert to JSON-encodable list
37 final result = dataPoints.map((dp) => {
38 'type': dp.typeString,
39 'value': dp.value.toString(),
40 'unit': dp.unitString,
41 'dateFrom': dp.dateFrom.toIso8601String(),
42 'dateTo': dp.dateTo.toIso8601String(),
43 }).toList();
44
45 return jsonEncode(result);
46}

Pro tip: If you are building for both iOS and Android, you can have a single Custom Action that checks `Platform.isIOS` to use the HealthKit path and `Platform.isAndroid` to use the Health Connect path — the `health` package API is identical for both.

Expected result: The Custom Action saves without Dart compilation errors and appears in your Actions list ready to be used in the Action Flow Editor.

3

Add Health Connect permission declarations to AndroidManifest.xml

Health Connect requires explicit permission declarations in `AndroidManifest.xml` before the permission dialog will appear. Unlike iOS where permissions flow through the `health` package initialization, Android requires you to list each Health Connect permission as a `<uses-permission>` element. FlutterFlow cannot set these permissions from within its visual interface — you must edit the exported Android project. Export your FlutterFlow project (Basic plan or higher, or use GitHub integration) and open the project in Android Studio or any text editor. Navigate to `android/app/src/main/AndroidManifest.xml`. Inside the `<manifest>` element (before the `<application>` tag), add a `<uses-permission>` line for each health data type you read. For steps, heart rate, sleep, and active calories, add the corresponding Health Connect permission strings. Also add a `<queries>` element to declare that your app can query the Health Connect app. After editing, rebuild the project and install on your Android device. Note that you may need to re-add these entries after future FlutterFlow exports — document them in your project notes.

AndroidManifest.xml
1<!-- Add to android/app/src/main/AndroidManifest.xml -->
2<!-- Inside <manifest>, before <application> -->
3<uses-permission android:name="android.permission.health.READ_STEPS" />
4<uses-permission android:name="android.permission.health.READ_HEART_RATE" />
5<uses-permission android:name="android.permission.health.READ_SLEEP" />
6<uses-permission android:name="android.permission.health.READ_ACTIVE_CALORIES_BURNED" />
7
8<!-- Also add inside <manifest> to declare Health Connect queries -->
9<queries>
10 <package android:name="com.google.android.apps.healthdata" />
11</queries>

Pro tip: The Health Connect permission strings use the `android.permission.health.READ_*` format introduced in Android 14. For older Android versions (9-13) with the Health Connect app installed from the Play Store, these same permissions work but the app must be granted access through the Health Connect app's permission manager.

Expected result: AndroidManifest.xml contains Health Connect permission declarations. Building and running on an Android device with Health Connect installed shows the Health Connect permission sheet when the Custom Action is triggered.

4

Trigger the action from a button and display results

In FlutterFlow, create an App State variable to store the health data. Go to App State in the left panel and click + Add State Variable — name it `healthDataJson`, type String, default value `'[]'`. Add a button to your page (for example, 'Sync Health Data') and open its Actions panel. In the Action Flow Editor, click + Add Action → Custom Action → getHealthConnectData. Map `startDate` to a DateTime value representing 7 days ago — create a Custom Function (Custom Code → + Add → Function) that returns `DateTime.now().subtract(const Duration(days: 7))` and use its output as the argument. Map `endDate` to a DateTime value for today (DateTime.now()). After the Custom Action completes, add an Update App State action to set `healthDataJson` to the action's return value (available under Action Outputs in the variable picker). Add a Text widget on the page bound to `healthDataJson` to verify data is flowing. For richer display, add FlutterFlow chart widgets and configure their data series from the parsed JSON values in App State. To show data immediately on page open, set the trigger to On Page Load rather than on a button tap. For a cross-platform build, also add the iOS HealthKit path using the HealthKit Custom Action (see healthkit page) on the same button, with a Conditional Action that checks `Platform.isIOS` first.

Pro tip: Always gate the On Page Load health data fetch with a check that the user has previously granted Health Connect permissions — re-requesting authorization on every page load is annoying. Store a boolean in App State or a Firestore user document indicating whether permissions were granted.

Expected result: Tapping the button (or triggering on page load) shows the Health Connect permission sheet on first run. After the user grants access, healthDataJson in App State updates with a JSON string of health data points.

5

Test on a real Android device with Health Connect installed

Health Connect Custom Actions will not work in FlutterFlow's web preview or Run mode — they will return empty data because `Platform.isAndroid` is false in a browser environment, which is the correct safe behavior. You must build and install on a real Android device. If you are using the exported project, open it in Android Studio and run directly on your connected Android device using the Run button. If you use the GitHub integration, clone the repo and run `flutter run` targeting your device. Before testing, ensure Health Connect is installed on the device: on Android 14+, it is built in under Settings → Health Connect. On Android 9-13, search for 'Health Connect' in the Play Store and install it. Add some test data to Health Connect — open the Health Connect app → Data and privacy → and either connect a fitness app or add test data manually. When your FlutterFlow app runs the Custom Action, it will show the Health Connect permission dialog listing the data types you requested. Tap Allow for each type. After granting permissions, the action reads data and returns it to App State. If Health Connect returns an empty list, confirm that the permission was granted in Health Connect app → App permissions → your app name.

Pro tip: On Android 13 and below where Health Connect is installed from the Play Store, users may need to open the Health Connect app and manually approve your app under App permissions if the in-app permission dialog does not appear.

Expected result: The app installed on a real Android device shows the Health Connect permission dialog. After the user grants access, health data appears in the FlutterFlow UI widgets as expected.

Common use cases

Cross-platform fitness tracker for iOS and Android

Build a fitness app that reads step count, calories, and heart rate from the native health store on each platform — HealthKit on iOS and Health Connect on Android — using a single `health` Custom Action with platform guards. Users get a consistent experience across both ecosystems without any backend health data storage.

FlutterFlow Prompt

A fitness dashboard that reads today's steps, active calories, and resting heart rate from the device's health store (HealthKit on iPhone, Health Connect on Android) and displays them in three metric cards at the top of the screen

Copy this prompt to try it in FlutterFlow

Android sleep quality tracker

Create a sleep-focused Android app that reads Health Connect sleep stage data (asleep, awake, REM, deep) recorded by devices like Fitbit, Garmin, or Pixel Watch that sync to Health Connect. Display a week-over-week sleep quality trend and highlight nights with low sleep scores.

FlutterFlow Prompt

A sleep tracker page for Android that pulls 30 days of Health Connect sleep data, shows average hours per night in a bar chart, and highlights the three best and three worst nights

Copy this prompt to try it in FlutterFlow

Corporate step challenge app

Build a gamified step-count challenge app for Android employees. Each participant's device reads their Health Connect step count for the day, which is submitted to Firestore via a Cloud Function. The leaderboard reads from Firestore and shows team rankings — Health Connect provides the data source while Firestore enables the social layer.

FlutterFlow Prompt

A step challenge leaderboard where each user's Health Connect daily steps are synced to a Firestore team document, and a sorted ListView shows all participants ranked by steps this week

Copy this prompt to try it in FlutterFlow

Troubleshooting

Empty data or MissingPluginException in FlutterFlow's web preview or Run mode

Cause: The `health` package requires native Android plugin code that cannot run in a browser. FlutterFlow's Run mode executes in a web context; Platform.isAndroid returns false and the plugin is not linked.

Solution: This is expected behavior — do not use the web preview to test Health Connect. Build and install on a real Android device via the exported project or GitHub integration. The Platform.isAndroid guard returns empty data gracefully without crashing.

Health Connect permission dialog never appears — requestAuthorization returns false silently

Cause: Health Connect is not installed on the device (common on Android 9-13), the AndroidManifest.xml is missing the required uses-permission declarations for Health Connect, or the device API level is below Android 9.

Solution: Verify Health Connect is installed: check Settings → Health Connect on Android 14+, or install from the Play Store on older versions. Confirm AndroidManifest.xml contains the android.permission.health.READ_* entries for each data type and the <queries> block for the Health Connect package. Rebuild and reinstall the app after editing AndroidManifest.xml.

Building against the old Google Fit REST API and seeing 401 or deprecated API warnings

Cause: The Google Fit REST API (googleapis.com/fitness) was deprecated in 2024. Google has restricted new access and may return errors for calls it previously served.

Solution: Migrate to Health Connect. Use the `health` Custom Action approach described on this page instead of the REST API. If you genuinely need a brief bridge period to migrate, the legacy REST path requires a Google OAuth 2.0 proxy through a Cloud Function — never put the OAuth client secret in Dart. Check the current deprecation timeline in Google's documentation.

Health data reads return an empty list even though the Health Connect app shows data

Cause: The date range passed to getHealthDataFromTypes does not overlap with available data, the specific HealthDataType has no records in that range, or the app permission in Health Connect was granted for some types but not the ones being read.

Solution: Check your startDate and endDate — ensure they cover days when health data was recorded. Open Health Connect app → Data and privacy → All data to confirm data exists. Check Health Connect → App permissions → your app to see which data types are authorized. Try extending the date range to 30 days to confirm data is available before narrowing it.

Best practices

  • Always guard Health Connect calls with `if (!Platform.isAndroid) return;` — Health Connect is Android-only and will throw on iOS and web without this guard
  • Use the same `health` pub.dev package for both Android Health Connect and iOS HealthKit — a single Custom Action with platform guards covers both ecosystems
  • Do not build new features against the deprecated Google Fit REST API — it will eventually stop working and Health Connect is the supported replacement
  • Document your AndroidManifest.xml Health Connect permission additions so they can be restored quickly after each FlutterFlow project re-export
  • Always test on a real Android device with Health Connect installed — the iOS Simulator cannot run Health Connect and FlutterFlow's web preview cannot run native Android plugins
  • Request only the Health Connect data types your feature actually needs — Android 14+ users can grant or deny individual permission types, and unused types reduce trust
  • Page your data requests by week rather than reading all-time health data — large datasets are slow to process and return from Health Connect

Alternatives

Frequently asked questions

Is the Google Fit REST API still usable in FlutterFlow?

Google deprecated the Google Fit REST API in 2024 and recommends all new integrations use Health Connect instead. Existing calls may still work during the deprecation window, but building anything new against the deprecated REST API is a dead end. For any new FlutterFlow health feature targeting Android, use the Health Connect path described on this page.

Does Health Connect work in FlutterFlow's web preview?

No. Health Connect is an on-device Android framework and cannot run in a browser. FlutterFlow's Run mode and web preview execute in a browser context where native Android plugins are unavailable. The Platform.isAndroid guard in your Custom Action returns false in the browser, so it gracefully returns empty data without crashing. Always test Health Connect on a real Android device.

Can I use the same `health` Custom Action for both Android and iOS users?

Yes. The `health` pub.dev package covers both Health Connect (Android) and HealthKit (iOS) under a unified API. Use Platform.isAndroid and Platform.isIOS guards in your Custom Action to call the right platform path. You will still need to handle platform-specific setup separately: Health Connect permissions in AndroidManifest.xml for Android, and HealthKit entitlement plus NSHealthShareUsageDescription for iOS.

What Android version does Health Connect require?

Health Connect is built into Android 14+ with no extra installation. On Android 9, 10, 11, 12, and 13, users need to install the Health Connect app from the Google Play Store. Devices running Android 8 or lower cannot use Health Connect. Your app should check for Health Connect availability before calling the permission request and show a friendly message if it is not installed.

Do I need a backend or API key to use Health Connect in FlutterFlow?

No. Health Connect is entirely on-device — there are no API keys, no OAuth flows, and no backend needed to read health data from Health Connect. Your Custom Action reads directly from the device's Health Connect store. You only need a backend if you want to sync or share that data across devices, or combine it with other users' data for social features like leaderboards.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Integrations are where projects stall

We wire FlutterFlow integrations like this one every week — auth, webhooks, edge cases included. Fixed-price builds from $13K, delivered in 6–10 weeks.

Talk to an integration engineer

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.