AutoCompleteTextFieldState<T> constructor
AutoCompleteTextFieldState<T> (
- StreamController<
List< placeSuggestionController,T> > - StringCallback? textChanged,
- StringCallback? textSubmitted,
- ValueSetter<
bool> ? onFocusChanged, - dynamic itemSubmitted(
- T
- AutoCompleteOverlayItemBuilder<
T> ? itemBuilder, - Comparator<
T> ? itemSorter, - Filter<
T> ? itemFilter, - int? suggestionsAmount,
- bool? submitOnSuggestionTap,
- bool? clearOnSubmit,
- int? minLength,
- List<
TextInputFormatter> ? inputFormatters, - TextCapitalization? textCapitalization,
- InputDecoration? decoration,
- TextStyle? style,
- TextInputType? keyboardType,
- TextInputAction? textInputAction,
- TextEditingController? controller,
- FocusNode? focusNode,
Implementation
AutoCompleteTextFieldState(
this.placeSuggestionController,
this.textChanged,
this.textSubmitted,
this.onFocusChanged,
this.itemSubmitted,
this.itemBuilder,
this.itemSorter,
this.itemFilter,
this.suggestionsAmount,
this.submitOnSuggestionTap,
this.clearOnSubmit,
this.minLength,
this.inputFormatters,
this.textCapitalization,
this.decoration,
this.style,
this.keyboardType,
this.textInputAction,
this.controller,
this.focusNode) {
try {
placeSuggestionController.stream.listen((event) {
suggestions = event;
});
} catch(e) {
//print("Error Listening to subscribed stream");
}
textField = TextField(
inputFormatters: inputFormatters,
textCapitalization: textCapitalization!,
decoration: decoration,
style: style,
keyboardType: keyboardType,
focusNode: focusNode ?? FocusNode(),
controller: controller ?? TextEditingController(),
textInputAction: textInputAction,
onChanged: (newText) {
currentText = newText;
updateOverlay(newText);
if (textChanged != null) {
textChanged!(newText);
}
},
onTap: () {
updateOverlay(currentText!);
},
onSubmitted: (submittedText) =>
triggerSubmitted(submittedText: submittedText),
);
if (controller != null && controller?.text != null) {
currentText = controller?.text;
}
textField?.focusNode?.addListener(() {
if (onFocusChanged != null) {
//onFocusChanged!(textField!.focusNode!.hasFocus);
}
if (!textField!.focusNode!.hasFocus) {
filteredSuggestions = [];
updateOverlay();
} else if (!(currentText == "" || currentText == null)) {
updateOverlay(currentText!);
}
});
}