Skip to content

Commit 47c43c9

Browse files
authored
Merge pull request #12 from joutvhu/develop
Fix insert integer digit
2 parents 729e916 + 072d345 commit 47c43c9

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed

lib/src/filter.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,6 @@ class TextNumberFilter {
186186
if (!allowing && startPosition < state.index) {
187187
state.remove(startPosition, state.index);
188188
}
189-
if (options.fixNumber) {
190-
state.prefix('0');
191-
integerDigits = 1;
192-
}
193189
allowing = true;
194190
startPosition = state.index;
195191
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: number_text_input_formatter
22
description: Number Text Input Formatter for Flutter
3-
version: 1.0.0+7
3+
version: 1.0.0+8
44

55
homepage: https://github.com/joutvhu/number_text_input_formatter
66
repository: https://github.com/joutvhu/number_text_input_formatter.git

test/number_text_input_formatter_test.dart

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,4 +1011,62 @@ void main() {
10111011
);
10121012
expect(result.text, '14%');
10131013
});
1014+
1015+
test('percentage_text_input_formatter_2', () {
1016+
var result = PercentageTextInputFormatter(
1017+
integerDigits: 12,
1018+
decimalDigits: 2,
1019+
decimalSeparator: '.',
1020+
groupDigits: 3,
1021+
groupSeparator: ',',
1022+
).formatEditUpdate(
1023+
const TextEditingValue(
1024+
text: '',
1025+
),
1026+
const TextEditingValue(
1027+
text: '.',
1028+
),
1029+
);
1030+
expect(result.text, '0.00');
1031+
});
1032+
1033+
test('percentage_text_input_formatter_3', () {
1034+
var result = PercentageTextInputFormatter(
1035+
integerDigits: 12,
1036+
decimalDigits: 2,
1037+
decimalSeparator: '.',
1038+
groupDigits: 3,
1039+
groupSeparator: ',',
1040+
allowNegative: true,
1041+
overrideDecimalPoint: false,
1042+
insertDecimalPoint: false,
1043+
insertDecimalDigits: false,
1044+
).formatEditUpdate(
1045+
const TextEditingValue(
1046+
text: '',
1047+
),
1048+
const TextEditingValue(
1049+
text: '-.',
1050+
),
1051+
);
1052+
expect(result.text, '-0.00');
1053+
});
1054+
1055+
test('percentage_text_input_formatter_4', () {
1056+
var result = PercentageTextInputFormatter(
1057+
integerDigits: 12,
1058+
decimalDigits: 2,
1059+
decimalSeparator: '.',
1060+
groupDigits: 3,
1061+
groupSeparator: ',',
1062+
).formatEditUpdate(
1063+
const TextEditingValue(
1064+
text: '',
1065+
),
1066+
const TextEditingValue(
1067+
text: '.24',
1068+
),
1069+
);
1070+
expect(result.text, '0.24');
1071+
});
10141072
}

0 commit comments

Comments
 (0)