flutter_money_formatter 0.5.3 copy "flutter_money_formatter: ^0.5.3" to clipboard
flutter_money_formatter: ^0.5.3 copied to clipboard

outdated

FlutterMoneyFormatter is an Flutter extension to formatting various types of currencies according to the characteristics you like, without having to be tied to any localization.

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.

latest version last commit License

Dependencies :

intl


Install #

For complete steps in installing FlutterMoneyFormatter you can see in the Installation Guide.

Usage #

Import the library

import 'package:flutter_money_formatter/flutter_money_formatter.dart';

Getting Started #

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:

FlutterMoneyFormatter fmf = FlutterMoneyFormatter(amount: 12345678.9012345);

Note, the code above still uses the default configuration as explained here.

After that you can request various results of the format as follows:

// normal form
print(fmf.formattedNonSymbol); // 12,345,678.90
print(fmf.formattedLeftSymbol); // $12,345,678.90
print(fmf.formattedRightSymbol); // 12,345,678.90$
print(fmf.fractionDigitsOnly); // 90
print(fmf.withoutDecimal); // 12,345,678

// compact form
print(fmf.compactNonSymbol) // 12.3M
print(fmf.compactLeftSymbol) // $12.3M
print(fmf.compactRightSymbol) // 12.3M$

See demo section to get more info.

Configurations #

To adjust the format to suit your needs, you can use my favorite notation way:

FlutterMoneyFormatter fmf = new FlutterMoneyFormatter(amount: 12345678.9012345)
    ..symbol = 'IDR'
    ..thousandSeparator = '.'
    ..decimalSeparator = ','
    ..fractionDigits = 3
    ..spaceBetweenSymbolAndNumber = true;

Of course, you don't need to change the whole properties like on above sample. By default the properties have the default values as follows:

Configuration Property Data Type Default Value Description
symbol String $ (Dollar Sign) The symbol that will be used on formatted output.
thousandSeparator String , The character that will be used as thousand separator on formatted output.
decimalSeparator String . The character that will be used as decimal separator on formatted output.
fractionDigits int 2 The fraction digits that will be used on formatted output.
spaceBetweenSymbolAndNumber bool false If the value is [true] then formatted output will shown space between the number and the currency symbol.
compactFormatType CompactFormatType CompactFormatType.sort Compact format type, sort or long type.

CompactFormatType #

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.sort Used to make the compact format displayed using sort text.
CompactFormatType.long Used to make the compact format displayed using long text.

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:

FlutterMoneyFormatter fmf = FlutterMoneyFormatter(amount: 12345678.9012345)

print(fmf.formattedLeftSymbol);
print(fmf.copyWith(symbol: 'IDR', spaceBetweenSymbolAndNumber: true).formattedLeftSymbol);

Complete Methods #

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.
CopyWith see here see here

Demo #

For more complete samples, you can grab it from the example directory.

Help Me #

If you find an issue, bug, question, or want to request a new feature you can do it here. You can also help me to improve features or fix some issues by forking this project via Github

ChangeLog #

Are you curious about the changes that occur in each version? See here for detailed informations.

96
likes
0
pub points
85%
popularity

Publisher

unverified uploader

FlutterMoneyFormatter is an Flutter extension to formatting various types of currencies according to the characteristics you like, without having to be tied to any localization.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, intl

More

Packages that depend on flutter_money_formatter