Repository: flutter
Issue: Navigator.Pop cause most recent focus node to regain focus even if not focused when new page was opened 
Labels: c: regression,platform-android,platform-ios,framework,f: routes,f: focus,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.19,found in release: 3.21

### Steps to reproduce

1. TextField with focus, keyboard showing
2. Clear focus from TextField
3. Open new page or dialog
4. Return to previous page with Navigator.pop

Issue started with upgrade to Flutter 3.19.0 and can't be reproduced with 3.16.9

### Expected results

No focus on TextField when returning to page
Since TextField did not have focus when new page was opened, expecting it not to gain focus from routing changes

### Actual results

TextField gains focus and keyboard showing

### 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(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text("Main page"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Padding(
              padding: EdgeInsets.all(24),
              child: TextField(
                autofocus: false,
              ),
            ),
            Text(
              FocusScope.of(context).hasFocus
                  ? 'Has focus'
                  : 'Does not have focus',
            ),
            ElevatedButton(
              onPressed: () => FocusScope.of(context).unfocus(),
              child: const Text("Clear focus"),
            ),
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => const SecondPage()),
                );
              },
              child: const Text("Open page"),
            ),
            ElevatedButton(
              child: const Text("Open dialog"),
              onPressed: () {
                showDialog(
                  context: context,
                  builder: (context) {
                    return AlertDialog(
                      title: const Text("Dialog"),
                      content: const Text("This is a dialog"),
                      actions: [
                        TextButton(
                          onPressed: () {
                            Navigator.pop(context);
                          },
                          child: const Text("Close"),
                        ),
                      ],
                    );
                  },
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  const SecondPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          title: const Text("Second page"),
          leading: IconButton(
            onPressed: () {
              Navigator.pop(context);
            },
            icon: const Icon(Icons.arrow_back),
          )),
      body: const Center(
        child: Text("This is the second page!"),
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Video demonstration</summary>


![Simulator Screen Recording - iPhone 14 Pro - 2024-03-14 at 16 40 46](https://github.com/flutter/flutter/assets/6470474/469fa9e5-1ad3-4332-90ed-744673ac0631)


</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.19.2, on macOS 14.4 23E214 darwin-arm64, locale en-SE)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.87.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
```

</details>