Repository: flutter
Issue: Focus: onFocusChanged(false) isn't called when Focus widget is detached
Labels: framework,d: api docs,f: focus,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.24,found in release: 3.26

### Steps to reproduce

In this demo https://dartpad.dev/?id=203fe4275aa7980f7ae568c41f5d96eb you'll find that if when you type anything into the input triggering its deletion and the deletion of the Focus widget, the Focus widget's onFocusChange handler isn't called.

### Expected results

There is a reasonable expectation that when focus moves away from a focused Focus, onFocusChange(false) should be called on that node.

### Actual results

focus moves away, but onFocusChange(false) is not called in this situation

(In my usecase, I'm genuinely not sure what to do about this. I tried moving a call to the unfocus code to dispose, but apparently you can't call Providers from dispose (edit: I did the thing recommended by the exception, copying state from the provider I needed into the state, to make sure we'd have it on dispose. Yuck. Note this workaround also requires naming and calling a change handler from two places instead of just the one.))

### Code sample

https://dartpad.dev/?id=203fe4275aa7980f7ae568c41f5d96eb

### Screenshots or Video

_No response_

### Logs

_No response_

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.24.1, on NixOS 23.11 (Tapir) 6.7.9, locale en_NZ.UTF-8)
    • Flutter version 3.24.1 on channel stable at
      /nix/store/ivslg1wbqmfcfhaxabdi36bd3cjvhnbq-flutter-wrapped-3.24.1-sdk-links
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision nixpkgs000 (), 1970-01-01 00:00:00
    • Engine revision c9b9d5780d
    • Dart version 3.5.1
    • DevTools version 2.37.2

[✗] Android toolchain - develop for Android devices
    • Android SDK at /home/mako/Android/Sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
    • clang version 18.1.8
    • cmake version 3.27.7
    • ninja version 1.12.1
    • pkg-config version 0.29.2

[!] Android Studio (version 2022.2)
    • Android Studio at
      /nix/store/nj9ncfr3mgwly9gagj6m59if5gp37k1g-android-studio-stable-2022.2.1.19-unwrapped
    • 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
    ✗ Failed to run Java: ProcessException: No such file or directory
        Command:
        /nix/store/nj9ncfr3mgwly9gagj6m59if5gp37k1g-android-studio-stable-2022.2.1.19-unwrapped/jbr/bin/ja
        va -version
    ✗ Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful,
      please let us know about this issue at https://github.com/flutter/flutter/issues.
    ✗ Error: Unable to run "adb", check your Android SDK installation and ANDROID_HOME environment
      variable: /home/mako/Android/Sdk/platform-tools/adb
      Error details: No such file or directory
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      AndroidDevices.pollingGetDevices
      (package:flutter_tools/src/android/android_device_discovery.dart:75:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:548:36)
      <asynchronous suspension>
      #3      Future.wait.<anonymous closure> (dart:async/future.dart:534:21)
      <asynchronous suspension>
      #4      DeviceManager.refreshAllDevices (package:flutter_tools/src/device.dart:218:40)
      <asynchronous suspension>
      #5      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:714:34)
      <asynchronous suspension>
      #6      Future.any.onValue (dart:async/future.dart:628:5)
      <asynchronous suspension>


[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 4 categories.

```

</details>