mask_text_input_formatter
mask_text_input_formatter copied to clipboard
Not working mask when add text by TextEditingController
Hi there, I cannot format textfield value by adding text by controller
final TextEditingController _numberKeyboardController =
TextEditingController();
final phoneTextFormatter = MaskTextInputFormatter(
mask: "+998 (••) ••• •• ••", filter: {"•": RegExp(r'[0-9]')});
// ui code
child: PhoneTextFiled(
maskTextInputFormatter: phoneTextFormatter,
controller: _numberKeyboardController,
showCursor: true,
readOnly: true),
),
NumberKeyboard(
onChanged: (_){
// from custom NumberKeyboard i pass number to controller
},
textEditingController: _numberKeyboardController,
),
// ui code
anything update yet?
The same issue
+1
The formatEditUpdate method is a mirror of Flutter's

The method is Called when text is being typed or cut/copy/pasted in the [EditableText].
This means that we can use that to format our text like so:
/// oldValue = _textController.value before assigning a new value to _textController.text and
/// newValue is _textController.value after having assigned it a new text value
_textController.value = _textFormatter.formatEditUpdate(oldValue, newValue);