From 5cfcfae616fc12e9cdeaa7fd19ddedb990f685da Mon Sep 17 00:00:00 2001 From: "rodrigo.castanon" Date: Mon, 11 Jan 2021 15:33:55 -0300 Subject: [PATCH] Add option to don't show keyboard when input is focused --- lib/src/chips_input.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/chips_input.dart b/lib/src/chips_input.dart index cfc00661..240537c4 100644 --- a/lib/src/chips_input.dart +++ b/lib/src/chips_input.dart @@ -52,6 +52,7 @@ class ChipsInput extends StatefulWidget { this.allowChipEditing = false, this.focusNode, this.initialSuggestions, + this.showKeyboard = true, }) : assert(maxChips == null || initialValue.length <= maxChips), super(key: key); @@ -78,6 +79,7 @@ class ChipsInput extends StatefulWidget { final bool allowChipEditing; final FocusNode focusNode; final List initialSuggestions; + final bool showKeyboard; // final Color cursorColor; @@ -164,8 +166,9 @@ class ChipsInputState extends State> void _handleFocusChanged() { if (_focusNode.hasFocus) { - _openInputConnection(); - _suggestionsBoxController.open(); + if (widget.showKeyboard) { + _openInputConnection(); + } } else { _closeInputConnectionIfNeeded(); _suggestionsBoxController.close(); @@ -262,6 +265,9 @@ class ChipsInputState extends State> _suggestionsBoxController.close(); } widget.onChanged(_chips.toList(growable: false)); + if (!widget.showKeyboard) { + _focusNode.unfocus(); + } } void deleteChip(T data) {