feat: initialize FocusNode in Popup and dispose it on close

This commit is contained in:
22
2025-11-01 11:12:36 +08:00
parent 376dc73296
commit 7d400b6199
2 changed files with 12 additions and 3 deletions

View File

@@ -26,10 +26,13 @@ class Popup<T> extends PopupRoute<T> {
Popup({
required this.child,
required this.direction,
});
}) {
_focusNode = FocusNode();
}
final Widget child;
final PopupDirection direction;
late final FocusNode _focusNode;
bool _isPopping = false;
@@ -51,11 +54,17 @@ class Popup<T> extends PopupRoute<T> {
@override
Duration get transitionDuration => const Duration(milliseconds: 250);
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
@override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return KeyboardListener(
focusNode: FocusNode(),
focusNode: _focusNode,
autofocus: true,
onKeyEvent: (event) {
if (event.logicalKey == LogicalKeyboardKey.escape) {

View File

@@ -89,4 +89,4 @@ msix_config:
trim_logo: false
languages: en-us, zh-cn
execution_alias: iris
file_extension: .aac, .aiff, .alac, .amr, .ape, .caf, .cda, .dsd, .dts, .flac, .m4a, .midi, .mp3, .mpc, .oga, .ogg, .opus, .raw, .spx, .tak, .tta, .wav, .wma, .wv, .3gp, .amv, .asf, .avi, .divx, .dpx, .drc, .dv, .f4v, .flv, .h264, .h265, .hevc, .m2ts, .m4p, .m4v, .mkv, .mng, .mov, .mp2, .mp4, .mpe, .mpeg, .mpg, .mpv, .mts, .mxf, .nsv, .ogv, .qt, .rm, .rmvb, .ts, .vob, .webm, .wmv, .yuv,
file_extension: .aac, .aiff, .alac, .amr, .ape, .caf, .cda, .dsd, .dts, .flac, .m4a, .midi, .mp3, .mpc, .oga, .ogg, .opus, .raw, .spx, .tak, .tta, .wav, .wma, .wv, .3gp, .amv, .asf, .avi, .divx, .dpx, .drc, .dv, .f4v, .flv, .h264, .h265, .hevc, .m2ts, .m4p, .m4v, .mkv, .mng, .mov, .mp2, .mp4, .mpe, .mpeg, .mpg, .mpv, .mts, .mxf, .nsv, .ogv, .qt, .rm, .rmvb, .ts, .vob, .webm, .wmv, .yuv