From ccd966a8120a6bbaf184b1f955e0b99001efc3da Mon Sep 17 00:00:00 2001 From: Malath Anaya Date: Tue, 14 Jun 2022 17:08:14 +0300 Subject: [PATCH] Allow passing text controller as a parameter of TagsTextField --- lib/src/suggestions_textfield.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/src/suggestions_textfield.dart b/lib/src/suggestions_textfield.dart index cd641c6..0e52c2c 100644 --- a/lib/src/suggestions_textfield.dart +++ b/lib/src/suggestions_textfield.dart @@ -25,7 +25,7 @@ class SuggestionsTextField extends StatefulWidget { } class _SuggestionsTextFieldState extends State { - final _controller = TextEditingController(); + TextEditingController _controller = TextEditingController(); List _matches = List(); String _helperText; @@ -48,6 +48,9 @@ class _SuggestionsTextFieldState extends State { _constraintSuggestion = widget.tagsTextField.constraintSuggestion; _inputDecoration = widget.tagsTextField.inputDecoration; _fontSize = widget.tagsTextField.textStyle.fontSize; + _controller = widget.tagsTextField.controller == null + ? _controller + : widget.tagsTextField.controller; return Stack( alignment: Alignment.centerLeft, @@ -195,7 +198,8 @@ class TagsTextField { this.maxLength, this.inputDecoration, this.onSubmitted, - this.onChanged}); + this.onChanged, + this.controller}); final double width; final EdgeInsets padding; @@ -220,4 +224,5 @@ class TagsTextField { final int maxLength; final OnSubmittedCallback onSubmitted; final OnChangedCallback onChanged; + final controller; }