gtgalone / currency_text_input_formatter

Currency Text Input Formatter for Flutter.
https://pub.dev/packages/currency_text_input_formatter
MIT License
50 stars 28 forks source link

Text selection bug #24

Closed Pomb closed 3 years ago

Pomb commented 3 years ago

Current behaviour A Field with a controller and an initial value, upon selecting the field text is highlighted as expected but then attempting to type in new values results in no changes.

Expected behaviour Selecting a field that has default text, highlights the current text, upon typing clears the field and starts as text input with formatting as usual as if there was no initial value.

Sample code.

TextEditingController _testController;
final FocusNode _testFocus = FocusNode();
final CurrencyTextInputFormatter _formatter = CurrencyTextInputFormatter(symbol: '$');

// init
_testController = TextEditingController(text: _formatter.format('123'));

_testFocus.addListener(() {
  _testController.selection = TextSelection(
      baseOffset: 0,
      extentOffset: _testController.text.length,
    );
 });

// build
TextFormField(
  focusNode: _testFocus,
  controller: _testController,
  keyboardType: TextInputType.number,
  inputFormatters: <TextInputFormatter>[_formatter],
),
gtgalone commented 3 years ago

@Pomb Thank you for issuing!

Sorry for late. My labtop was in repair :)

and I have just published 2.1.2 with fixing this issue.

Please use 2.1.2.