FlutterMoneyFormatter는 Flutter 애플리케이션에서 유연한 통화 형식을 지원하는 Dart 패키지입니다. 개발자는 소수점 자릿수, 기호 위치, 천 단위 구분자 등을 사용자 정의하여 금액 표시 방식을 조정할 수 있으며, 시스템 로컬라이제이션에 의존하지 않습니다. 이로 인해 다양한 지역에서 일관된 브랜드 통화 표시가 필요한 앱에 이상적입니다. 패키지는 다양한 포맷팅 옵션을 지원하며 기존 Flutter 프로젝트에 원활하게 통합됩니다.
사용 사례
전자상거래 앱에서의 사용자 정의 통화 표시
특정 소수 규칙으로 가격 형식 지정
로컬라이즈된 시스템 외 통화 표시
일관된 스타일을 갖춘 재무 대시보드
단일 앱에서의 다국화 통화 지원
주요 기능
사용자 정의 가능한 소수 및 천 단위 구분 기호
유연한 통화 기호 위치
시스템 로컬라이제이션에 의존하지 않음
다중 통화 형식 지원
Flutter 위젯과의 간편한 통합
적합한 대상
브랜드 통화 형식이 필요한 개발자
국제 사용자 기반을 가진 앱
금융 또는 유통 애플리케이션
플랫폼별 로컬라이제이션을 피하는 프로젝트
숫자 형식화에 대한 통제를 원하는 팀
고려 사항
자동 통화 변환을 지원하지 않습니다
각 형식에 대해 수동 구성이 필요합니다
표시 형식에만 제한되며 구문 분석은 포함되지 않음
실시간 환율 교환 수요에는 적합하지 않습니다
동적 통화 전환을 위한 추가 로직이 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
FlutterMoneyFormatter
FlutterMoneyFormatter is a Flutter extension to formatting various types of currencies according to the characteristics you like, without having to be tied to any localization.
Dependencies :
Screenshot
Install
For complete steps in installing FlutterMoneyFormatter you can see in the Installation Guide.
To be able to format your double value into the various formats you want, you first need to create a FlutterMoneyFormatter instance like the following:
Of course you are not required to initialize the entire configuration in the settings (MoneyFormatterSettings) parameter as in the example above. You can change one or more of the configurations above. This is because each configuration above is not mandatory and has a default value.
You can change the type of compact format like for million using M or million, or trillion using T or trillion. and so on. This type only supports two type as described below:
Value
Description
CompactFormatType.short
Used to make the compact format displayed using short text.
CompactFormatType.long
Used to make the compact format displayed using long text.
MoneyFormatterOutput
You can use formats that match your needs through properties found in the MoneyFormatterOutput instance.
Property Names
Data Type
Descriptions
nonSymbol
String
The results of the format of the currency are normal and without a currency symbol. Example: 12,345,678.90
symbolOnLeft
String
The results of the normal currency format and with currency symbols are on the left. Example: $ 12,345,678.90
symbolOnRight
String
The results of the normal currency format and with currency symbols are on the right. Example: 12,345,678.90 $
compactNonSymbol
String
The results of the currency format are compact and without a currency symbol. Example: 12.3M
compactSymbolOnLeft
String
The results of the currency format are compact and with currency symbols on the left. example: $ 12.3M
compactSymbolOnRight
String
The results of the currency format are compact and with currency symbols on the right. example: 12.3M $
fractionDigitsOnly
String
Only give the fraction value. Example: 90
withoutFractionDigits
String
Give a value without fractions. Example: 12,345,678
MoneyFormatterCompare
Method
Parameter
Descriptions
isLowerThan
amount
Check current instance-amount is lower than [amount] or not.
isGreaterThan
amount
Check current instance-amount is greater than [amount] or not.
isEqual
amount
Check current instance amount is equal than [amount] or not.
isEqualOrLowerThan
amount
Check current instance amount is equal or lower than [amount] or not.
isEqualOrGreaterThan
amount
Check current instance amount is equal or greater than [amount] or not.
fastCalc is a function that can be used to perform various fast calculation processes that you might need. In implementing it, the fastCalc function gives the output of a FlutterMoneyFormatter instance so you can perform several calculation functions at once with the chaining method.
The type parameter used by the fastCalc function has the FastCalcType data type which is an enum. The following table is an explanation for the FastCalcType enum:
Index
Name
Description
0
addition
Used to do addition calculations.
1
substraction
Used to do substraction calculations.
2
multiplication
Used to do multiplication calculations.
3
division
Used to do division calculations.
4
percentageAddition
Used to do the addition calculations base on percentage.
5
percentageSubstraction
Used to do the substraction calculations base on percentage.
Duplicating Instance
For some reasons, you may need to duplicate the instance and just need to change some configurations. To do that, you can use the copyWith method as below:
Copyright (c) 2019, Fadhly Permata <fadhly.permata@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the 'FlutterMoneyFormatter' project.