From 70f87c73fc5f02b9bdb3be3bea9eb6db07e7f249 Mon Sep 17 00:00:00 2001 From: Siyi Guo Date: Thu, 13 Apr 2023 19:18:32 +0800 Subject: [PATCH] optimize the use exciress --- lib/image/drag.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/image/drag.dart b/lib/image/drag.dart index 75eb55b..5ed2b6c 100644 --- a/lib/image/drag.dart +++ b/lib/image/drag.dart @@ -31,12 +31,12 @@ class _DraggableAreaState extends State { bool isPressShift = false; Axis? get axis { - if (isPressCommand) { - return Axis.vertical; - } if (isPressShift) { return Axis.horizontal; } + if (isPressCommand) { + return Axis.vertical; + } return null; } @@ -101,8 +101,11 @@ class _DraggableAreaState extends State { setState(() {}); } if (value is KeyUpEvent && isShift(value)) { - isPressShift = false; - setState(() {}); + Future.delayed(const Duration(milliseconds: 500)).then((value) { + isPressShift = false; + if (!mounted) return; + setState(() {}); + }); } if (value is! KeyDownEvent && value is! KeyRepeatEvent) { return KeyEventResult.ignored;