Repository: flutter
Issue: Web: Autofill doesn't populate fields with TouchID enabled 
Labels: a: text input,framework,platform-web,has reproducible steps,P2,team-web,triaged-web,fyi-text-input,found in release: 3.22,found in release: 3.24

### Steps to reproduce

I'm using Mac 

using Safari browser:

1. Enable Touch ID for autofilling passwords on your Mac.
2. Run the code on the web using Safari.
3. Choose the suggested username/password from the password manager.
4. A Touch ID popup will appear. Provide your biometrics or password.

using Chrome:

1. Enable Touch ID for autofilling passwords on your Mac.
2. In Chrome open Google Password Manager -> Settings -> Make sure that "Use your screen lock when filling in passwords" is turned on and "Sign in automatically" is turned off. 
3. Re-open browser
4. Run the code on the web using Chrome
5. Save username & password for this user and localhost and try to login again using suggestions from the password manager.
6. A Touch ID popup will appear. Provide your biometrics or password.

### Expected results

When I provide either fingerprint or password for TouchId and it is correct, username(email) and password fields should be populated with data from password manager. 

### Actual results

Nothing happens. Fields seem to loose focus and are not prefilled. 

In Safari -> Fields are only prefilled when you use touchId directly, without selecting username from the list first. So without loosing focus to the field.  Otherwise you are blocked and cannot populate data using autofill. 
In Chrome -> On second try you are not asked again about TouchId, so autofill works. In that case focus is not lost from the TextFormField that is why it seems to work. 

### Code sample

I tried to reproduce this problem with a minimal codebase needed to isolate the issue. It still exists in this simple demo, which led me to create this bug report.

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: LoginForm(),
    );
  }
}

//code example from https://medium.com/@debasishkumardas5/streamline-user-input-with-flutter-auto-fill-integration-a-comprehensive-guide-37058a597e3e

class LoginForm extends StatefulWidget {
  @override
  _LoginFormState createState() => _LoginFormState();
}

class _LoginFormState extends State<LoginForm> with WidgetsBindingObserver {
  final _formKey = GlobalKey<FormState>();
  final _usernameController = TextEditingController();
  final _passwordController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Auto-fill Example'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Form(
          key: _formKey,
          child: AutofillGroup(
            child: Column(
              children: [
                TextFormField(
                  controller: _usernameController,
                  autofillHints: const [AutofillHints.email],
                  decoration: const InputDecoration(
                    labelText: 'Email',
                  ),
                ),
                TextFormField(
                  controller: _passwordController,
                  autofillHints: const [AutofillHints.password],
                  obscureText: true,
                  decoration: const InputDecoration(
                    labelText: 'Password',
                  ),
                ),
                ElevatedButton(
                  onPressed: () {
                    if (_formKey.currentState!.validate()) {
                      TextInput.finishAutofillContext();
                      // Submit form
                    }
                  },
                  child: const Text('Submit'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>


https://github.com/user-attachments/assets/395ef386-cdb9-4b11-8f3d-7e852c7b6b6b


</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

I work mostly with Flutter web version, that's why Android SDK was not installed.

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.22.3, on macOS 14.4 23E214 darwin-arm64, locale en-AT)
    • Flutter version 3.22.3 on channel stable at /Users/ania/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (2 weeks ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.89.0)
    • VS Code at /Users/ania/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.92.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.4 23E214 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.4 23E214 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 127.0.6533.89

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
```

</details>