Skip to content

Commit

Permalink
4.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Macacoazul01 committed Jun 3, 2024
1 parent 2a3124d commit aee9a1e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [4.9.1] - 2024-06-02
- Fixed a bug that caused minus sign to not disappear when the value of the controller is 0.[18](https://github.com/IsaiasSantana/currency_textfield/issues/18).
- Removed unnecessary call to the listener.

## [4.9.0] - 2024-06-01
- Fixed `symbolSeparator` not reseting if `startWithSeparator` was set to false.[17](https://github.com/IsaiasSantana/currency_textfield/issues/17).
- Fixed [16](https://github.com/IsaiasSantana/currency_textfield/issues/16).
Expand Down
21 changes: 14 additions & 7 deletions lib/currency_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,22 @@ class CurrencyTextFieldController extends TextEditingController {
}

if (text.isEmpty) {
_zeroValue();
_zeroValue(resetText: false);
return;
}

checkNegative();

if (text == '-') {
_previewsText = '-';
return;
}

late String clearText;

if (_currencyOnLeft) {
clearText = (_getOnlyNumbers(string: text) ?? '').trim();
} else {
// TODO corrigir erro de negativo
if (text.lastChars(1).isNumeric()) {
clearText = (_getOnlyNumbers(string: text) ?? '').trim();
} else {
Expand Down Expand Up @@ -272,12 +276,15 @@ class CurrencyTextFieldController extends TextEditingController {
selection = TextSelection.fromPosition(TextPosition(offset: offset));
}

///force the sign when `_value = 0`
void _zeroValue() {
///resets the controller to 0.
void _zeroValue({bool resetText = true}) {
_value = 0;
_previewsText = _negativeSign();
text = _previewsText;
_setSelectionBy(offset: text.length);
_isNegative = false;
_previewsText = '';
if (resetText) {
text = _previewsText;
_setSelectionBy(offset: 0);
}
if (_resetSeparator && _startWithSeparator) {
_startWithSeparator = false;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: currency_textfield
description: A flutter package that implements a Controller for currency text input.
version: 4.9.0
version: 4.9.1
homepage: https://github.com/IsaiasSantana/currency_textfield
environment:
sdk: '>=3.0.0 <4.0.0'
Expand Down

0 comments on commit aee9a1e

Please sign in to comment.