Repository: flutter
Issue: Whether focus exists has nothing to do with whether the keyboard is open
Labels: a: text input,platform-android,framework,engine,f: focus,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.16,found in release: 3.18

### Steps to reproduce

Related issues:

https://github.com/flutter/flutter/issues/123523

Related Pull Requests:

https://github.com/flutter/engine/pull/41500
https://github.com/flutter/flutter/pull/123929

There should be no correlation between whether the keyboard is open and whether focus exists. Should keep focus after keyboard was closed.

related comments:
https://github.com/flutter/engine/pull/41500#issuecomment-1852785103
https://github.com/flutter/engine/pull/40746#issuecomment-1819189977


### Expected results

Keep focus when keyboard was closed.

https://private-user-images.githubusercontent.com/30322203/228413196-29c57bb0-3220-495b-9e73-f58777de440f.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDMxNTg1NDEsIm5iZiI6MTcwMzE1ODI0MSwicGF0aCI6Ii8zMDMyMjIwMy8yMjg0MTMxOTYtMjljNTdiYjAtMzIyMC00OTViLTllNzMtZjU4Nzc3ZGU0NDBmLm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzEyMjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMjIxVDExMzA0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJiMjhkMjI3Mjk2YzlmZDQ1NTQyMGM4MGI0MmQ3YTJmZTI2ODViYmVhYmJiYTU5ODdhYmM4MWYyY2VkN2Y2ZjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.D2QHCNuSE4ebCgWj6IvEnqj05khWcAiRKE3fCCbnoXI


### Actual results

the focus is gone after the keyboard is closed

https://private-user-images.githubusercontent.com/30322203/228413249-fc06f49d-6579-4476-9788-90f12a53b8c3.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDMxNTg1NDEsIm5iZiI6MTcwMzE1ODI0MSwicGF0aCI6Ii8zMDMyMjIwMy8yMjg0MTMyNDktZmMwNmY0OWQtNjU3OS00NDc2LTk3ODgtOTBmMTJhNTNiOGMzLm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzEyMjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMjIxVDExMzA0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU0ZjhkOWFkMmFhYWQ2NWExNzE1ZDQ5OGFiYjk5N2YyNjViZTJkNGE4ZDA0YWMxYmY3OTg5MDU1ZGUxYjVlZWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Iu9IgUHNaN03fxlEZxyjfpCQMXF4371Blj0MzJQFjaY



### 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(
        primarySwatch: Colors.blue,
      ),
      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> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: const <Widget>[TextField()],
        ),
      ),
    );
  }
}
```

</details>

### Flutter Doctor output

<details open><summary>Doctor</summary>

```
[!] Flutter (Channel [user-branch], 3.18.0-14.0.pre.46, on macOS 14.2.1 23C71
    darwin-arm64, locale zh-Hans-CN)
    ! Flutter version 3.18.0-14.0.pre.46 on channel [user-branch] at
      /Users/yangjiakang/flutter/framework
      Currently on an unknown channel. Run `flutter channel` to switch to an
      official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions
      at https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss
      this error.
    • Framework revision d746007fcd (12 小时前), 2023-12-20 16:19:59 -0800
    • Engine revision c70f0a495a
    • Dart version 3.3.0 (build 3.3.0-244.0.dev)
    • DevTools version 2.31.0-dev.0
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/yangjiakang/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/yangjiakang/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C65
    ! CocoaPods 1.11.3 out of date (1.13.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
      for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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-17.0.6b829.9-10027231)

[!] Android Studio (version unknown)
    • Android Studio at
      /Users/yangjiakang/Code/androidx/studio/android-studio-2023.1.1.15-mac_arm
      /Android Studio Preview.app/Contents
    • 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
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build
      17.0.7+0-17.0.7b1000.6-10550314)

[!] Android Studio (version unknown)
    • Android Studio at
      /Users/yangjiakang/Code/aosp/frameworks/support/studio/android-studio-2023
      .2.1.4-mac_arm/Android Studio Preview.app/Contents
    • 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
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build
      17.0.8+0-17.0.8b1000.22-10799086)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • 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

[✓] VS Code (version 1.85.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.78.0

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 4 categories.
```

</details>