Get started using App Check in Flutter apps

This page shows you how to enable App Check in a Flutter app, using thedefault providers: Play Integrity on Android, Device Check on Apple platforms, andreCAPTCHA v3 on web. When you enable App Check, you help ensure thatonly your app can access your project's Firebase resources. See anOverview of this feature.

1. Set up your Firebase project

  1. Install and initialize FlutterFire if you haven'talready done so.

  2. Register your apps to use App Check with the Play Integrity, Device Check, and reCAPTCHA providers in theProject Settings > App Checksection of the Firebase console.

    You usually need to register all of your project's apps, because once youenable enforcement for a Firebase product, only registered apps will be ableto access the product's backend resources.

  3. Optional: In the app registration settings, set a custom time-to-live(TTL) for App Check tokens issued by the provider. You can set the TTLto any value between 30 minutes and 7 days. When changing this value, beaware of the following tradeoffs:

    • Security: Shorter TTLs provide stronger security, because it reduces thewindow in which a leaked or intercepted token can be abused by anattacker.
    • Performance: Shorter TTLs mean your app will perform attestation morefrequently. Because the app attestation process adds latency to networkrequests every time it's performed, a short TTL can impact the performanceof your app.
    • Quota and cost: Shorter TTLs and frequent re-attestation deplete yourquota faster, and for paid services, potentially cost more.SeeQuotas & limits.

    The default TTLis reasonable for most apps. Note that the App Check library refreshestokens at approximately half the TTL duration.

2. Add the App Check library to your app

  1. From the root of your Flutter project, run the following command to install the plugin:

    flutterpubaddfirebase_app_check
  2. Once complete, rebuild your Flutter application:

    flutterrun

3. Initialize App Check

Add the following initialization code to your app so that it runs before youuse any Firebase services such as Storage, but after callingFirebase.initializeApp();

import'package:flutter/material.dart';import'package:firebase_core/firebase_core.dart';// Import the firebase_app_check pluginimport'package:firebase_app_check/firebase_app_check.dart';Future<void>main()async{WidgetsFlutterBinding.ensureInitialized();awaitFirebase.initializeApp();awaitFirebaseAppCheck.instance.activate(// You can also use a `ReCaptchaEnterpriseProvider` provider instance as an// argument for `webProvider`webProvider:ReCaptchaV3Provider('recaptcha-v3-site-key'),// Default provider for Android is the Play Integrity provider. You can use the "AndroidProvider" enum to choose// your preferred provider. Choose from:// 1. Debug provider// 2. Safety Net provider// 3. Play Integrity providerandroidProvider:AndroidProvider.debug,// Default provider for iOS/macOS is the Device Check provider. You can use the "AppleProvider" enum to choose// your preferred provider. Choose from:// 1. Debug provider// 2. Device Check provider// 3. App Attest provider// 4. App Attest provider with fallback to Device Check provider (App Attest provider is only available on iOS 14.0+, macOS 14.0+)appleProvider:AppleProvider.appAttest,);runApp(App());}

Next steps

Once the App Check library is installed in your app, start distributing theupdated app to your users.

The updated client app will begin sending App Check tokens along with everyrequest it makes to Firebase, but Firebase products will not require the tokensto be valid until you enable enforcement in the App Check section of theFirebase console.

Monitor metrics and enable enforcement

Before you enable enforcement, however, you should make sure that doing so won'tdisrupt your existing legitimate users. On the other hand, if you're seeingsuspicious use of your app resources, you might want to enable enforcementsooner.

To help make this decision, you can look at App Check metrics for theservices you use:

Enable App Check enforcement

When you understand how App Check will affect your users and you're ready toproceed, you can enable App Check enforcement:

Use App Check in debug environments

If, after you have registered your app for App Check, you want to run yourapp in an environment that App Check would normally not classify as valid,such as an emulator during development, or from a continuous integration (CI)environment, you can create a debug build of your app that uses theApp Check debug provider instead of a real attestation provider.

SeeUse App Check with the debug provider in Flutter apps.

Note: For certain Android devices, you need to enable "Meets basic deviceintegrity" in the Google Play console.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-10 UTC.