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

Add option to don't show keyboard when input is focused #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/src/chips_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ChipsInput<T> extends StatefulWidget {
this.allowChipEditing = false,
this.focusNode,
this.initialSuggestions,
this.showKeyboard = true,
}) : assert(maxChips == null || initialValue.length <= maxChips),
super(key: key);

Expand All @@ -78,6 +79,7 @@ class ChipsInput<T> extends StatefulWidget {
final bool allowChipEditing;
final FocusNode focusNode;
final List<T> initialSuggestions;
final bool showKeyboard;

// final Color cursorColor;

Expand Down Expand Up @@ -164,8 +166,9 @@ class ChipsInputState<T> extends State<ChipsInput<T>>

void _handleFocusChanged() {
if (_focusNode.hasFocus) {
_openInputConnection();
_suggestionsBoxController.open();
if (widget.showKeyboard) {
_openInputConnection();
}
} else {
_closeInputConnectionIfNeeded();
_suggestionsBoxController.close();
Expand Down Expand Up @@ -262,6 +265,9 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
_suggestionsBoxController.close();
}
widget.onChanged(_chips.toList(growable: false));
if (!widget.showKeyboard) {
_focusNode.unfocus();
}
}

void deleteChip(T data) {
Expand Down