Skip to content

Commit a6b2d0c

Browse files
committed
fixed #111
1 parent 4e1c17b commit a6b2d0c

4 files changed

Lines changed: 30 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## [2.9.14]
2+
- Fixed https://github.com/caseyryan/flutter_multi_formatter/issues/111
13
## [2.9.11]
24
- Added promptTonesForPinyin() static function to PinyinUtils.
35
It can give you a list of its vowels with all possible tones

example/lib/pages/money_format_page.dart

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ class _MoneyFormatPageState extends State<MoneyFormatPage> {
1616

1717
@override
1818
Widget build(BuildContext context) {
19-
// print(toCurrencyString(
20-
// 1000.0.toString(),
21-
// trailingSymbol: '',
22-
// thousandSeparator: ThousandSeparator.Period,
23-
// mantissaLength: 0,
24-
// ));
19+
print(
20+
toCurrencyString(
21+
'M1,1111'.toString(),
22+
mantissaLength: 0,
23+
thousandSeparator: ThousandSeparator.Comma,
24+
leadingSymbol: 'M',
25+
),
26+
);
27+
2528
return Unfocuser(
2629
child: Scaffold(
2730
appBar: AppBar(
@@ -59,12 +62,15 @@ class _MoneyFormatPageState extends State<MoneyFormatPage> {
5962
),
6063
inputFormatters: [
6164
CurrencyInputFormatter(
62-
// thousandSeparator: ThousandSeparator.Comma,
63-
// mantissaLength: 0,
64-
thousandSeparator: ThousandSeparator.Space,
65-
mantissaLength: 2,
66-
trailingSymbol: "\$",
67-
)
65+
mantissaLength: 0,
66+
thousandSeparator: ThousandSeparator.Comma,
67+
leadingSymbol: 'M',
68+
),
69+
// CurrencyInputFormatter(
70+
// thousandSeparator: ThousandSeparator.Space,
71+
// mantissaLength: 2,
72+
// trailingSymbol: "\$",
73+
// )
6874
],
6975
),
7076
SizedBox(
@@ -312,8 +318,7 @@ class _MoneyFormatPageState extends State<MoneyFormatPage> {
312318
CurrencyInputFormatter(
313319
leadingSymbol: CurrencySymbols.DOLLAR_SIGN,
314320
useSymbolPadding: true,
315-
thousandSeparator:
316-
ThousandSeparator.SpaceAndPeriodMantissa,
321+
thousandSeparator: ThousandSeparator.SpaceAndPeriodMantissa,
317322
// ThousandSeparator.Comma,
318323
)
319324
],
@@ -338,8 +343,7 @@ class _MoneyFormatPageState extends State<MoneyFormatPage> {
338343
),
339344
inputFormatters: [
340345
CurrencyInputFormatter(
341-
thousandSeparator:
342-
ThousandSeparator.SpaceAndPeriodMantissa,
346+
thousandSeparator: ThousandSeparator.SpaceAndPeriodMantissa,
343347
trailingSymbol: ' USD',
344348
// ThousandSeparator.Comma,
345349
)
@@ -365,8 +369,7 @@ class _MoneyFormatPageState extends State<MoneyFormatPage> {
365369
),
366370
inputFormatters: [
367371
CurrencyInputFormatter(
368-
thousandSeparator:
369-
ThousandSeparator.SpaceAndCommaMantissa,
372+
thousandSeparator: ThousandSeparator.SpaceAndCommaMantissa,
370373
trailingSymbol: ' U',
371374
// ThousandSeparator.Comma,
372375
)

lib/formatters/formatter_utils.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ String toCurrencyString(
505505
}
506506
String mSeparator = _getMantissaSeparator(thousandSeparator, mantissaLength);
507507
String tSeparator = _getThousandSeparator(thousandSeparator);
508-
String? fractionalSeparator = _detectFractionSeparator(value);
508+
String? fractionalSeparator =
509+
mantissaLength > 0 ? _detectFractionSeparator(value) : null;
509510

510511
var sb = StringBuffer();
511512
bool addedMantissaSeparator = false;
@@ -531,8 +532,7 @@ String toCurrencyString(
531532
}
532533

533534
final str = sb.toString();
534-
final evenPart =
535-
addedMantissaSeparator ? str.substring(0, str.indexOf('.')) : str;
535+
final evenPart = addedMantissaSeparator ? str.substring(0, str.indexOf('.')) : str;
536536

537537
int skipEvenNumbers = 0;
538538
String shorteningName = '';

lib/utils/pinyin_utils.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,8 @@ class PinyinUtils {
777777
subsyllables.first.currentSyllable,
778778
),
779779
);
780-
} else if (_hasIncomplete(subsyllables)) {
780+
} else if (_hasIncomplete(subsyllables) ||
781+
(allPossibleSentences?.isEmpty == true && subsyllables.isNotEmpty)) {
781782
allPossibleSentences ??= [];
782783
String tempValue = simplified;
783784
_Sentence sentence = _Sentence(
@@ -808,8 +809,7 @@ class PinyinUtils {
808809
removePunctuation: removePunctuation,
809810
);
810811
} else {
811-
final maxScoredSentences =
812-
_getSentencesWithMaxScore(allPossibleSentences!);
812+
final maxScoredSentences = _getSentencesWithMaxScore(allPossibleSentences!);
813813
allPossibleSentences.clear();
814814
allPossibleSentences.addAll(maxScoredSentences);
815815
}
@@ -1034,8 +1034,7 @@ class _Sentence {
10341034
}
10351035
if (rankByUse) {
10361036
for (var r in _correctSequence!) {
1037-
List<HanziRankInfo> rankInfo =
1038-
HanziUtils.findHanziRankByPinyin(r.value);
1037+
List<HanziRankInfo> rankInfo = HanziUtils.findHanziRankByPinyin(r.value);
10391038
int rank = rankInfo.firstOrNull?.fequencyRank ?? 10000;
10401039
_totalUseRank += rank;
10411040
}

0 commit comments

Comments
 (0)