# Add Fingerprint and Face ID Login to a Flutter App

Yes. An agent adds biometric unlock to your Flutter app with local_auth, wires the Android and iOS permissions, adds the setting and strings, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-biometric-auth/flutter/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and reads how login works today before it adds a second way in. In an app like simplezhli/flutter_deer, `pubspec.yaml` (`version: 1.3.3+22`, Dart `>=3.4.0 <4.0.0`, Flutter `>=3.19.0`) lists `provider`, `fluro` for routing, `sp_util` for shared preferences, `flutter_localizations` with `intl` and `generate: true`, `device_info_plus`, `quick_actions` and `window_manager` for desktop. `lib/login/page/login_page.dart` holds a phone and a password controller; `_verify()` enables the button when the phone has at least 11 characters and the password at least 6, and `_login()` stores the phone under `Constant.phone` with `SpUtil.putString` and pushes `StoreRouter.auditPage`. There is no token exchange in this demo, which the agent notes: biometric unlock will gate the saved session, and the pull request says where a real app would decrypt its token instead.

It reads the rest of the path a returning user takes. `lib/home/splash_page.dart` checks `Constant.keyGuide` in `_initSplash()` and calls `_goLogin()`, which replaces the route with `LoginRouter.loginPage`. `lib/res/constant.dart` defines the preference keys (`keyGuide`, `phone`, `accessToken`, `refreshToken`, `theme`, `locale`). `lib/setting/page/setting_page.dart` is a list of `ClickItem`s (account manager, clear cache, dark mode, language, check update, about, sign out), several guarded by `Device.isMobile`, and `lib/setting/page/account_manager_page.dart` already has the `修改密码` row that goes to `LoginRouter.updatePasswordPage`. Strings live in `lib/l10n/intl_en.arb` and `intl_zh.arb`, compiled into `deer_localizations.dart`. On the platform side, `android/app/src/main/java/com/weilu/deer/MainActivity.java` extends `FlutterActivity`, `AndroidManifest.xml` declares only `INTERNET` and `REQUEST_INSTALL_PACKAGES`, and `ios/Runner/Info.plist` has camera, location and photo usage strings but no `NSFaceIDUsageDescription`.

The agent adds `local_auth` to `pubspec.yaml` and writes `lib/util/biometric_utils.dart`: a small class over `LocalAuthentication` that reports whether the device supports biometrics (`isDeviceSupported`, `getAvailableBiometrics`) and runs `authenticate` with a localized reason and `biometricOnly: true`, mapping the plugin's `PlatformException` codes (`NotAvailable`, `NotEnrolled`, `LockedOut`) to messages. A new `Constant.biometricLogin` key stores the opt-in. In `account_manager_page.dart` a `指纹/面容登录` row with a switch appears only on mobile when the device supports it, and turning it on requires one successful prompt. In `login_page.dart`, when the opt-in is set and a phone is saved, a fingerprint button appears under the password field and the prompt also opens on first build; success runs the same navigation `_login()` does. Both ARB files get the new strings and `flutter gen-l10n` regenerates the localizations.

Platform changes follow the plugin's requirements: `MainActivity` extends `FlutterFragmentActivity` instead of `FlutterActivity` (the existing `configureFlutterEngine` and status bar code stay), `AndroidManifest.xml` gains `android.permission.USE_BIOMETRIC`, and `Info.plist` gains `NSFaceIDUsageDescription`. Desktop and web builds are untouched because every new widget sits behind the same `Device.isMobile` guard the settings page already uses. The agent adds a widget test that pumps `LoginPage` with a fake `LocalAuthPlatform` to cover the button and the two outcomes, adds the page to `test/login/login_accessibility_test.dart` so the new button meets `labeledTapTargetGuideline`, and runs `flutter analyze` (the repository's `analysis_options.yaml` has `strict-casts`, `strict-inference` and `strict-raw-types`) and `flutter test` in the sandbox.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add biometric login to this Flutter app with the local_auth package. Read the login flow, the splash and settings pages, the preference keys and the localization setup first. Add an opt-in switch in the account settings that is shown only on mobile devices that support biometrics, store the choice in shared preferences, and on the login page offer a fingerprint or face prompt when the opt-in is set and a saved account exists; success must take the same path as a password login. Make the Android and iOS changes the plugin requires, add the new strings to every ARB file, and keep desktop and web builds unchanged. Add a widget test with a fake platform implementation and run flutter analyze and flutter test. Open a pull request that explains what the biometric prompt unlocks in this app and what a production app should do differently.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request on its own branch that changes `pubspec.yaml` and `pubspec.lock`, `lib/res/constant.dart`, `lib/login/page/login_page.dart`, `lib/setting/page/account_manager_page.dart`, both ARB files and the generated localizations, `MainActivity.java`, `AndroidManifest.xml` and `Info.plist`, and adds `lib/util/biometric_utils.dart` and `test/login/biometric_login_test.dart`. The description shows the two screens as described, quotes the `flutter analyze` and `flutter test` output from the sandbox, and has a section on what the prompt protects in this app versus one with real tokens.

The run's record keeps every command with its output, including the Flutter SDK the sandbox installed, `flutter pub get`, `flutter gen-l10n`, the analyzer run and each test, so a reviewer sees the exact versions and that no analyzer warning was introduced.

Before merging, a reviewer runs the app on a real device or an emulator with a fingerprint enrolled, since the sandbox has no biometric hardware, checks the Face ID usage string wording, decides whether a device credential fallback (`biometricOnly: false`) is wanted, and confirms the minimum Android SDK the plugin needs matches `flutter.minSdkVersion` in `android/app/build.gradle`.

## Run it on every Linear issue labelled agent

In the console, an automation in the Project that has the repository, with a `linear` trigger on `linear.issue.labeled` and `config.labels` set to `agent`, starts one run per issue, with the issue text added after the prompt. A product ticket that names the screens and whether a PIN fallback is wanted reaches the agent as part of that text, and the pull request links the issue.

From your own server, the same work is one `POST /o/{org}/sessions` with this body and the repository in `resources`; a webhook on the API key reports `run.completed` with the `session_url` to read the pull request link.

## Why run it on Rush?

Biometric login touches Dart, Java, a manifest, a plist, two string files and a test, and the plugin's requirements (the fragment activity, the permission, the usage string) are the kind of thing a developer finds out from a crash on a device. The agent reads the plugin's documentation and the app's existing routing and preference code first, so the feature lands in the places the app already uses rather than beside them.

The sandbox is a real Linux computer: the agent installs the Flutter SDK, runs `flutter analyze` and `flutter test`, and the output stays in the run's record as proof. It cannot touch a fingerprint sensor, and the pull request says so instead of claiming a device test. Several apps, or several platforms of one app, can be done at once in separate sandboxes.

## Frequently asked questions

### What does the biometric prompt actually protect?

Whatever your login stores. In a demo whose login saves only a phone number, the prompt gates returning to the signed-in screens. In an app with tokens, the agent keeps them in secure storage and reads them only after a successful prompt, and the pull request says which it did.

### Will it break desktop or web builds?

No. The new widgets are shown only on mobile, behind the same guard the settings page already uses, and `local_auth` has no-op behaviour where the platform is unsupported. The agent runs the analyzer over the whole project to confirm nothing else changed.

### Why does MainActivity have to change?

The plugin shows the Android biometric prompt from a fragment, so the host activity must be a `FlutterFragmentActivity`. The agent changes the superclass and keeps the existing engine configuration and status bar code; nothing else in the activity moves.

### Does it add a PIN or passcode fallback?

Only if you ask. The default is `biometricOnly: true`, so an unenrolled or locked-out device gets a clear message and the password form. Set `biometricOnly: false` in the prompt and the system passcode becomes the fallback.

## More Flutter jobs

- [Add Dev and Production Build Flavors to a Flutter App](https://getrush.ai/run/add-build-flavors/flutter/)
- [Add Test Coverage Reporting to a Flutter App's CI](https://getrush.ai/run/add-coverage-to-ci/flutter/)
- [Add Crash Reporting to a Flutter App](https://getrush.ai/run/add-crash-reporting/flutter/)

## The same job on other stacks

- [Add Biometric Login to a React Native App](https://getrush.ai/run/add-biometric-auth/react-native/)
- [Add Biometric Login to an Expo App from a Linear Issue](https://getrush.ai/run/add-biometric-auth/expo/)

## More jobs like this: Turn a Linear label into a PR

- [Add a Blog Dashboard to a Filament Admin Panel from a Linear Issue](https://getrush.ai/run/add-blog-dashboard/filament/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
