From f57d5d2c891bbf02d7ccbfcc2be6f7d9162d2b76 Mon Sep 17 00:00:00 2001 From: blackkitten Date: Sun, 19 Jan 2025 16:53:04 +0100 Subject: [PATCH] fix for #25 - block open if already open, block close if not open --- lib/controllers/dropdown_controller.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/controllers/dropdown_controller.dart b/lib/controllers/dropdown_controller.dart index dee7cd3..52ea874 100644 --- a/lib/controllers/dropdown_controller.dart +++ b/lib/controllers/dropdown_controller.dart @@ -112,6 +112,8 @@ class DropdownController implements TickerProvider { ); void show({required BuildContext context, required DropdownWidget child}) { + if (_isOpen) return; + _overlayEntry = OverlayEntry(builder: (_) => child); if (_overlayEntry == null) return; Overlay.of(context).insert(_overlayEntry!); @@ -123,10 +125,13 @@ class DropdownController implements TickerProvider { } void open() { + if (_isOpen) return; + openFunction!.call(); } void close() async { + if (!_isOpen) return; await _controller.reverse(); _overlayEntry?.remove(); @@ -152,8 +157,7 @@ class DropdownController implements TickerProvider { } Future resetError() async { - _setErrorDecorationTween( - errorDecorationTween.end!, _isOpen ? _resultOptions.openBoxDecoration : _resultOptions.boxDecoration); + _setErrorDecorationTween(errorDecorationTween.end!, _isOpen ? _resultOptions.openBoxDecoration : _resultOptions.boxDecoration); _errorController.reset(); await _errorController.forward(); _onError?.call(false);