Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Exception in AnimationController if disposed whilst actively animating #48

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
32 changes: 17 additions & 15 deletions lib/dropdown_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class IconProperty {
class CheckBoxProperty {
final MouseCursor? mouseCursor;
final Color? activeColor;
final MaterialStateProperty<Color?>? fillColor;
final WidgetStateProperty<Color?>? fillColor;
final Color? checkColor;
final bool tristate;
final MaterialTapTargetSize? materialTapTargetSize;
final VisualDensity? visualDensity;
final Color? focusColor;
final Color? hoverColor;
final MaterialStateProperty<Color?>? overlayColor;
final WidgetStateProperty<Color?>? overlayColor;
final double? splashRadius;
final FocusNode? focusNode;
final bool autofocus;
Expand Down Expand Up @@ -557,19 +557,21 @@ class _DropDownTextFieldState extends State<DropDownTextField>
enabled: widget.isEnabled,
readOnly: widget.readOnly,
onTapOutside: (event) {
final RenderBox renderBox =
overlayKey.currentContext?.findRenderObject() as RenderBox;
final overlayPosition = renderBox.localToGlobal(Offset.zero);
final overlaySize = renderBox.size;
bool isOverlayTap = (overlayPosition.dx <= event.position.dx &&
event.position.dx <=
overlayPosition.dx + overlaySize.width) &&
(overlayPosition.dy <= event.position.dy &&
event.position.dy <=
overlayPosition.dy + overlaySize.height);

if (!isOverlayTap) {
_textFieldFocusNode.unfocus();
if (overlayKey.currentContext != null) {
final RenderBox renderBox =
overlayKey.currentContext?.findRenderObject() as RenderBox;
final overlayPosition = renderBox.localToGlobal(Offset.zero);
final overlaySize = renderBox.size;
bool isOverlayTap = (overlayPosition.dx <= event.position.dx &&
event.position.dx <=
overlayPosition.dx + overlaySize.width) &&
(overlayPosition.dy <= event.position.dy &&
event.position.dy <=
overlayPosition.dy + overlaySize.height);

if (!isOverlayTap) {
_textFieldFocusNode.unfocus();
}
}
},
onTap: () {
Expand Down