Repository: flutter
Issue: PageView shows old page data if TextField inside its pages still keeps the focus while navigating between pages
Labels: a: text input,platform-android,platform-ios,framework,f: focus,has reproducible steps,P2,workaround available,found in release: 3.10,found in release: 3.11,team-framework,triaged-framework

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [x] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Introduction:

Pageview shows old page data. 

When I make a list of pages for a pageview, where page 2 is dynamically chosen based upon the choice on page 1, flutter updates page 2 according expectations. 
However, when you add a textfield to both page2A and page2B (as in the provided example code) and fill it with some text there is an issue where old data is shown. 

### Steps to reproduce:
1. Run the example
2. Swipe to page 2
3. Put in some text into the text field (for example the text page2A) and do not press the keyboard 'done' button. 
4. Swipe back to page 1
5. Toggle the checkbox to toggle page2A vs page2B
6. Swipe to page 2
7. Find your old text typed at step 2 in a different page / widget. 

In my application the problem is even bigger, page2A and page2B are completely different forms, and when you fill in one of the textfields of the form, and change the choice on page1, and navigate back to page2, you get the previous choice of form as page contents. So not only the TextField contains old data, the whole page does not get updated and contains the wrong Text widgets. 

### Expected results

I expect to see the contents in the textfield that are from the page I selected. 

### Actual results

The contents of a textfield of a different page are shown. 

### Code sample

<details><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 PageView weird behavior',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter PageView weird behavior'),
    );
  }
}

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 showPage2a = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme
            .of(context)
            .colorScheme
            .inversePrimary,
        title: Text(widget.title),
      ),
      body: PageView.builder(itemBuilder: (BuildContext context, int index) {
        List<Widget> pages = getPages();
        if (pages.length > index) {
          return pages[index];
        }
        else {
          return null;
        }
      }),
    );
  }

  List<Widget> getPages() {
    return [
      page1(),
      if(showPage2a) page2a(),
      if(!showPage2a) page2b(),
    ];
  }

  Widget page1() {
    return ListView(children: [
      Text("Page1"),
      CheckboxListTile(title: Text("Show page2a?") , value: showPage2a, onChanged: (value) {
        setState(() {
          showPage2a = !showPage2a;
        });
      }),

    ],
    );
  }

  Widget page2a() {
    return ListView(children: [
      Text("Page2a"),
      TextField(),
    ],
    );
  }

  Widget page2b() {
    return ListView(children: [
      Text("Page2b"),
      TextField(),
    ],
    );
  }
}

```

</details>


### Screenshots or Video
On Samsung Galaxy S22 phone running android 13:
https://github.com/flutter/flutter/assets/87121128/af891512-1ad8-4027-bbbf-dd5d1b1dd373

On iOS simulator (iPhone SE 3rd generation) (can test a real iphone later)

https://github.com/flutter/flutter/assets/87121128/88ef1f70-8e55-4aa6-b819-da0138b207e3

On Android Simulator (Pixel_3a) running android 13:

https://github.com/flutter/flutter/assets/87121128/60ec4aa6-cfc2-4644-8105-c7c42010a03a



### Logs

_No response_

### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[√] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.22621.1702], locale en-NL)
    • Flutter version 3.10.0 on channel stable at c:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (6 days ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\Username\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33530.505
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] VS Code (version 1.78.2)
    • VS Code at C:\Users\Username\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
    • SM S901B (mobile) • R3CT50J3RWA • android-arm64  • Android 13 (API 33)
    • Windows (desktop) • windows     • windows-x64    • Microsoft Windows [Version 10.0.22621.1702]
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 113.0.5672.93
    • Edge (web)        • edge        • web-javascript • Microsoft Edge 113.0.1774.35

[√] Network resources
    • All expected network resources are available.

• No issues found!

```

</details>