Skip to content

Commit 7d400b6

Browse files
committed
feat: initialize FocusNode in Popup and dispose it on close
1 parent 376dc73 commit 7d400b6

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

lib/widgets/popup.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ class Popup<T> extends PopupRoute<T> {
2626
Popup({
2727
required this.child,
2828
required this.direction,
29-
});
29+
}) {
30+
_focusNode = FocusNode();
31+
}
3032

3133
final Widget child;
3234
final PopupDirection direction;
35+
late final FocusNode _focusNode;
3336

3437
bool _isPopping = false;
3538

@@ -51,11 +54,17 @@ class Popup<T> extends PopupRoute<T> {
5154
@override
5255
Duration get transitionDuration => const Duration(milliseconds: 250);
5356

57+
@override
58+
void dispose() {
59+
_focusNode.dispose();
60+
super.dispose();
61+
}
62+
5463
@override
5564
Widget buildPage(BuildContext context, Animation<double> animation,
5665
Animation<double> secondaryAnimation) {
5766
return KeyboardListener(
58-
focusNode: FocusNode(),
67+
focusNode: _focusNode,
5968
autofocus: true,
6069
onKeyEvent: (event) {
6170
if (event.logicalKey == LogicalKeyboardKey.escape) {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ msix_config:
8989
trim_logo: false
9090
languages: en-us, zh-cn
9191
execution_alias: iris
92-
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,
92+
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

0 commit comments

Comments
 (0)