From 4e61c210889187e9c3e4a5e14ab1487c0c36194d Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 9 Jul 2020 17:51:01 +0200 Subject: [PATCH] NoteTagEditor: Add the tag when hitting Enter --- lib/widgets/note_tag_editor.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/widgets/note_tag_editor.dart b/lib/widgets/note_tag_editor.dart index 2c8bd3a9..acb3e5ec 100644 --- a/lib/widgets/note_tag_editor.dart +++ b/lib/widgets/note_tag_editor.dart @@ -53,6 +53,7 @@ class _NoteTagEditorState extends State { hintText: tr('editors.common.tags'), hintStyle: theme.inputDecorationTheme.hintStyle, ), + onSubmitted: _addTag, ), ), body: buildView(_textController.text), @@ -109,13 +110,15 @@ class _NoteTagEditorState extends State { return ListTile( leading: const Icon(Icons.add), title: Text(tag), - onTap: () { - setState(() { - _selectedTags.add(tag); - _allTags.add(tag); - _textController.text = ""; - }); - }, + onTap: () => _addTag(tag), ); } + + void _addTag(String tag) { + setState(() { + _selectedTags.add(tag); + _allTags.add(tag); + _textController.text = ""; + }); + } }