Repository: flutter
Issue: Unexpected autofill behavior in Safari
Labels: a: text input,platform-web,has reproducible steps,browser: safari-macos,P2,team-web,triaged-web,found in release: 3.24,found in release: 3.27

### Steps to reproduce

Run an app in Safari

1. Use a field with credit card autofill enabled, confirm autofill with touch id
2. Find any other field (in the provided example you can tap the button to switch the content)
3. Enter something in the other field, then delete it

### Expected results

There are no autofill prompts in the second field, where autofill isn't setup or `autofillHints` is set to `null`.

### Actual results

Autofill proposes credit card data for the second field.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.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: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool _showCardField = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            _showCardField
                ? const AutofillGroup(
                    child: TextField(
                      decoration: InputDecoration(
                        hintText: 'Credit card number',
                      ),
                      autofillHints: [AutofillHints.creditCardNumber],
                    ),
                  )
                : const TextField(
                    decoration: InputDecoration(
                      hintText: 'Random field',
                    ),
                    autofillHints: null,
                  ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () => setState(() => _showCardField = !_showCardField),
              child: const Text('Switch'),
            )
          ],
        ),
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

https://github.com/user-attachments/assets/fd9a355a-767d-4d5c-b11d-c708e6f5b605

</details>

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.0 24A335 darwin-arm64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[!] Android Studio (version unknown)
    ✗ Unable to determine Android Studio version.
    ✗ Unable to find bundled Java version.
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Community Edition (version 2023.1)
[✓] VS Code (version 1.94.2)
[✓] Connected device (4 available)
[✓] Network resources

! Doctor found issues in 1 category.
```

</details>