Repository: flutter
Issue: TextFormField not focus again after recall or navigate to the other(or pushReplace to the same screen) screen
Labels: waiting for customer response,in triage

### Steps to reproduce

1. Create 2 textField, bold of them have focusNode
2. after submit TextFiled1 , request focus on TextField2.
3. When TextField2 Submitted: call API 
 + if success response : clear all textField and request focus at textField1
 + if error: show Aleart Dialog



### Expected results

after textField2 submitted, call API success have to show snackbar and focus again at textField1

### Actual results

The problem is some time it work but sometime didn't.
When successs there is few case happened like:
+ show the cursor at textField1, keyboard show up and disappear immediately.
+ not showing cursor and keyboard
+ show cursor and keyboard but typing not working


### Code sample

<details open><summary>Code sample</summary>

```dart
class DaoChuyenHangXuatKhau extends StatefulWidget {
  const DaoChuyenHangXuatKhau({super.key});

  @override
  State<DaoChuyenHangXuatKhau> createState() => _DaoChuyenHangXuatKhauState();
}

class _DaoChuyenHangXuatKhauState extends State<DaoChuyenHangXuatKhau> {
  TextEditingController maPalletController = TextEditingController();
  TextEditingController maDMVitriController = TextEditingController();
  TextEditingController ghiChuController = TextEditingController();

  var fcMaPallet = FocusNode();
  var fcViTri = FocusNode();
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      fcMaPallet.requestFocus();
    });

  }

  @override
  void dispose() {
    maPalletController.dispose();
    maDMVitriController.dispose();
    ghiChuController.dispose();
    fcMaPallet = FocusNode();
    fcViTri = FocusNode();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Đảo chuyển hàng xuất khẩu'),
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
        child: Column(
          children: [
            TextField(
              focusNode: fcMaPallet,
              onSubmitted: (value) {
                fcViTri.requestFocus();
              },
              decoration: InputDecoration(
                label: const Text('Mã Pallet'),
                border: OutlineInputBorder(
                  borderSide: const BorderSide(width: 10),
                  borderRadius: BorderRadius.circular(10),
                ),
              ),
              controller: maPalletController,
            ),
            const SizedBox(height: 10),
            TextField(
              focusNode: fcViTri,
              decoration: InputDecoration(
                label: const Text('Mã vị trí kho'),
                border: OutlineInputBorder(
                  borderSide: const BorderSide(width: 10),
                  borderRadius: BorderRadius.circular(10),
                ),
              ),
              controller: maDMVitriController,
              onSubmitted: (value) async {
                if (maPalletController.text.isNotEmpty && value.isNotEmpty) {
                  // fcViTri.unfocus();
                  // await DaoChuyen2(context);
                  // fcMaPallet.requestFocus();
                  ProgressDialog(context);
                  //Kiểm tra trùng vị trí kho
                  await ctDaoChuyenHangXuatKhauListCheckViTriKho(
                      ctDaoChuyenHangXuatKhauListCheckViTriKhoRequest(
                    MaDanhMucViTriKho: maDMVitriController.text,
                  )).then((response) async {
                    Navigator.of(context).pop();
                    if (response.Status == '0') {
                      if (response.Data == "1") {
                        QuestionMessageDialog(context,
                            "Vị trí kho đã có hàng, bạn có muốn đặt trùng vị trí kho hay không?",
                            () async {
                          await DaoChuyen(context);
                        });
                      } else {
                        await DaoChuyen(context);
                      }
                    } else {
                      ErrorMessageDialog(context, response.ErrorMsg, () {});
                    }
                  });
                } else {
                  ErrorMessageDialog(
                      context, "Hãy quét đủ mã pallet và vị trí ", () {});
                }
              },
            ),
            const SizedBox(
              height: 20,
            ),
            TextFormField(
              decoration: InputDecoration(
                label: const Text('Ghi chú'),
                border: OutlineInputBorder(
                  borderSide: const BorderSide(width: 10),
                  borderRadius: BorderRadius.circular(10),
                ),
              ),
              controller: ghiChuController,
            ),
            const SizedBox(
              height: 10,
            ),
          ],
        ),
      ),
    );
  }

  Future<void> DaoChuyen(BuildContext context) async {
    ProgressDialog(context);
    await ctDaoChuyenHangXuatKhauInsert(ctDaoChuyenHangXuatKhauInsertRequest(
            ID: '',
            IDDanhMucDonVi: IDDanhMucDonVi,
            IDDanhMucChungTu: '',
            IDDanhMucChungTuTrangThai: '',
            MaPallet: maPalletController.text,
            MaDanhMucViTriKho: maDMVitriController.text,
            IDDanhMucNguoiSuDungCreate: IDDanhMucNguoiSuDung,
            GhiChu: ghiChuController.text))
        .then((value) {
      Navigator.of(context).pop();
      //  log('pop lần 1 trong đảo chuyển');

      if (value.Status == '0') {
        setState(() {
          maPalletController.text = "";
          maDMVitriController.text = "";

        });

        ScaffoldMessenger.of(context).showSnackBar(SnackBar(
            backgroundColor: Colors.green[300],
            duration: const Duration(milliseconds: 1000),
            content: const Text(
              "Cập nhật thành công",
              style: TextStyle(fontSize: 20),
            )));
        Future.delayed(const Duration(microseconds: 300))
            .then((value) => WidgetsBinding.instance.addPostFrameCallback((_) {
                  fcMaPallet.requestFocus();
                }));
        // Navigator.of(context).pushReplacement(
        //     MaterialPageRoute(builder: (_) => const DaoChuyenHangXuatKhau()));
      } else {
        ErrorMessageDialog(context, value.ErrorMsg, () {});
      }
    });
  }
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>


https://github.com/user-attachments/assets/563acd8e-cf69-4285-89c5-42cdef302e41



</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[√] Flutter (Channel stable, 3.16.2-0.0.pre.1, on Microsoft Windows [Version 10.0.19045.3570], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.4)
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK
[√] Android Studio (version 2023.1)
[√] IntelliJ IDEA Community Edition (version 2024.1)
[√] VS Code (version 1.96.2)
[√] Connected device (3 available)
[√] Network resources
```

</details>