PerfectTextController constructor
PerfectTextController({})
Implementation
PerfectTextController({
TextEditingController? textEditingController,
FocusNode? focusNode,
bool selectAllOnFocus = true,
bool readyOnly = false,
this.onTextChange,
this.onFocusChange,
}) : textController = textEditingController ?? TextEditingController(),
focusNode = focusNode ??
(readyOnly
? FocusNode(
skipTraversal: true,
canRequestFocus: false,
descendantsAreFocusable: false,
descendantsAreTraversable: false,
)
: FocusNode()) {
textController.addListener(() {
if (rxText.value != textController.text) {
rxText.value = textController.text;
}
if (onTextChange != null) {
onTextChange?.call(text);
}
});
this.focusNode.addListener(() {
PerfectTextController.focused =
this.focusNode.hasPrimaryFocus ? this : null;
if (selectAllOnFocus) {
onFocusChange?.call(this.focusNode.hasPrimaryFocus);
if (this.focusNode.hasPrimaryFocus) {
selectAll();
}
}
});
}