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

outdated

FlutterMoneyFormatter is a Flutter extension that can be used to handle currency formats that are not bound by the operating system configuration.

FlutterMoneyFormatter #

pub-version dart-sdk intl

FlutterMoneyFormatter is a Flutter extension that can be used to handle currency formats that are not bound by the operating system configuration.

In formatting currencies, you can easily do it without having to make your own formatter. Because FlutterMoneyFormatter is indeed designed to work independently and has complete utilities.

logo

Install #

For the complete step, the installation of Flutter Money Formatter can be seen here. : Installation Guide

Usage #

Import the library

import 'package:flutter_money_formatter/flutter_money_formatter.dart';

Getting Started #

To be able to format the double value into the various formats you want, you first need to create a FlutterMoneyFormatter instance like the following:

FlutterMoneyFormatter fmf = FlutterMoneyFormatter(value: 12345678.9012345);

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

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

Configurations #

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

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

Of course, you don't need to change the whole notation above. By default the parameters above have the default values as follows:

Notation 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.

Duplicating Instance #

For some reasons, you may need to duplicate the instance and change some configurations. To do that, you can use the copyWith method as below:

FlutterMoneyFormatter fmf = FlutterMoneyFormatter(value: 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
96
likes
0
pub points
85%
popularity

Publisher

unverified uploader

FlutterMoneyFormatter is a Flutter extension that can be used to handle currency formats that are not bound by the operating system configuration.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, intl

More

Packages that depend on flutter_money_formatter