Price Text – Flutter
A customizable Price Text for Flutter apps.
Format and display prices in multiple currencies with flags, symbols, and localized formatting.
✨ Features
✅ Supports multiple currencies (USD, EUR, GBP, INR, JPY, AUD, CAD, CNY, SGD, NZD, MXN, ZAR, TRY).
✅ Automatically formats numbers with proper separators and decimals.
✅ Localized currency formatting using intl.
✅ Display currency code, symbol, and even country flag.
✅ Supports custom text style and color logic (positive/negative/custom).
✅ Plug & Play → Simply using PriceText with any screen.
How to use it ?
1. Add dependency
Add this to your package's pubspec.yaml file:
dependencies:
price_text: <latest_version>
2. Install it You can install packages from the command line:
with pub :
$ pub get
with Flutter :
$ flutter pub get
3. Import it
Now in your Dart code, you can use :
import 'package:price_text/price_Text.dart';
4. Use it
Sample app demonstrates how simple the usage of the library actually is.
Using PriceText in your project is super simple.
You just need to add the widget with an amount and currency type, and it will handle formatting for you.
Basic usage
Without any customization:
//Example usage of PriceText
PriceText(
currencyType: CurrencyType.USD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen using currency format
),
show flag :
PriceText(
currencyType: CurrencyType.USD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen using currency format
showFlag: true, //to show flag of the country
),
show showCurrencyCode :
PriceText(
currencyType: CurrencyType.USD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen using currency format
showFlag: true, //to show flag of the country
showCurrencyCode: true, //to show currency code
),
customize with CurrencyCode Text and TextStyle :
PriceText(
currencyType: CurrencyType.USD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen using currency format
showFlag: true, //to show flag of the country
showCurrencyCode: true, //to show currency code
currencyCodeText: 'Us Dollar', //custom currency code text
currencyCodeTextStyle: TextStyle(color: Colors.black, fontSize: 20,fontWeight: FontWeight.w600), //custom style for currency code text
),
customize with flagspacing and alignment(left-right) :
| Flag Left (default) | Flag Right |
|---|---|
PriceText(
currencyType: CurrencyType.USD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen using currency format
showFlag: true, //to show flag of the country
showCurrencyCode: true, //to show currency code
flagSpacing: 30,// to space betweenflag and currencyText
flagAlignment: AlignmentOption.right,//to align flag left-right side
),
customize flag using image assets :
PriceText(
currencyType: CurrencyType.AUD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen using currency format
showFlag: true, //to show flag of the country
showCurrencyCode: true, //to show currency code
/// custom flag widget using image asset
customFlagWidget: Image.asset(
'assets/aud.png',
height: 40,
width: 40,
fit: BoxFit.cover
),
),
hide Currency symbol :
PriceText(
currencyType: CurrencyType.AUD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen using currency format
showFlag: true, //to show flag of the country
showCurrencyCode: true, //to show currency code
hideCurrencySymbol: true, //to hide currency symbol like $, ₹ etc
),
avoid Currency format :
PriceText(
currencyType: CurrencyType.AUD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen using currency format
showFlag: true, //to show flag of the country
showCurrencyCode: true, //to show currency code
avoidCurrencyFormat: true,//to avoid currency format like : 1,000.00 and show 1000 without formatting
),
positive and negative value changes color Bydefault :
| Colors (Positive value) | Colors (Negative value) | Colors (Zero value) |
|---|---|---|
/// show nagative red color default
PriceText(
currencyType: CurrencyType.AUD, //for currency type to be displayed
amount: -1000, //for amount to be displayed on screen nagative value to show red color
showFlag: true, //to show flag of the country
howCurrencyCode: true, //to show currency code
),
/// show positive value green color default
PriceText(
currencyType: CurrencyType.AUD, //for currency type to be displayed
amount: 1000, //for amount to be displayed on screen positive value to show green color
showFlag: true, //to show flag of the country
howCurrencyCode: true, //to show currency code
),
/// show 0 value grey color bydefult
PriceText(
currencyType: CurrencyType.AUD, //for currency type to be displayed
amount: 0, //for amount to be displayed on screen 0 value to show grey color
showFlag: true, //to show flag of the country
howCurrencyCode: true, //to show currency code
),
customize positive and negative value changes color according to your choice :
| Colors (Positive value) | Colors (Negative value) | Colors (Zero value) |
|---|---|---|
/// changes text color according amountColorStyle
PriceText(
currencyType: CurrencyType.AUD, //for currency type to be displayed
amount: 0, //for amount to be displayed on screen 0 value to show black color
showFlag: true, //to show flag of the country
showCurrencyCode: true, //to show currency code.
/// to change color of amount based on value
amountColorStyle: (num amount) {
if (amount > 0) {
return Colors.blue; // for positive value
} else if (amount < 0) {
return Colors.purpleAccent; // for nagative value
} else {
return Colors.black; // for 0 value
}
},
),
Use Currency locale for using formatting
The locale property allows you to set the regional formatting for your currency display.
Supported locales:INR → en_IN, USD → en_US, CAD → en_CA, EUR → en_IE, GBP → en_GB, JPY → ja_JP, AUD → en_AU, CNY → zh_CN, SGD → en_SG, NZD → en_NZ, MXN → es_MX, ZAR → en_ZA, TRY → tr_TR
PriceText(
currencyType: CurrencyType.USD, //for currency type to be displayed
amount: 12345.67, //for amount to be displayed on screen 0 value to show grey color
locale: "en_US", //locale for formatting
),
Use Currency formatterPattern
The formatterPattern property lets you customize the number format of the amount.
PriceText(
currencyType: CurrencyType.USD, //for currency type to be displayed
amount: 12345.67, //for amount to be displayed on screen 0 value to show grey color
locale: "en_US", //locale for formatting
formatterPattern: '#,##0.0', //custom pattern for formatting
),
All Code Customization Options :
Basic Options
- currencyType → select currency
- amount → enter amount (0 = grey)
- showFlag → show/hide country flag
- showCurrencyCode → show/hide currency code
Layout
- contryCodeSpacing → space between flag & code
- flagSpacing → space between code & amount
- flagAlignment → flag left / right
Styling
- amountColorStyle → customize color according to your choice
- positive = green
- negative = red
- zero = grey
- hideCurrencySymbol → hide symbol, only show amount
- avoidCurrencyFormat → disable auto-formatting
Advanced
- customFlagWidget → use your own flag image/widget
- currencyCodeText → replace code with custom text (e.g., US,AUD)
- currencyCodeTextStyle → custom text style
Supported Currencies:
- USD, EUR, GBP, INR, JPY, AUD, CAD, CNY, SGD, NZD, MXN, ZAR, TRY
- Example : CurrencyType.AUD, // add according your choice
PriceText(
/// Supported Currencies: USD, EUR, GBP, INR, JPY, AUD, CAD, CNY, SGD, NZD, MXN, ZAR, TRY
currencyType: CurrencyType.AUD, //for currency type to be displayed
locale: "en_AU", //locale for formatting
formatterPattern: '#,##0.00', //custom pattern for formatting
amount: 2000, //for amount to be displayed on screen 0 value to show grey color
showFlag: true, //to show flag of the country
showCurrencyCode: true, //to show currency code
ontryCodeSpacing: 10, //spacing between flag and currency code
flagSpacing: 20, //spacing between currency code and amount
flagAlignment: AlignmentOption.left, //flag alignment left or right
amountColorStyle: (amount) {
if (amount > 0) {
return Colors.green;
} else if (amount < 0) {
return Colors.red;
} else {
return Colors.grey;
}
}, //custom color resolver for amount
hideCurrencySymbol: false, //to hide currency symbol if you want to show only amount
avoidCurrencyFormat: false, //to avoid currency formatting
customFlagWidget: Image.asset('assets/aud.png', width: 40, height: 40,fit: BoxFit.cover,), //custom flag widget if you want to show custom flag using image
currencyCodeText: 'australia', //custom currency code text if you want to show custom text
currencyCodeTextStyle: const TextStyle(fontSize: 22, fontWeight: FontWeight.w500), //custom text style for currency code
),
Bugs and Feedback
We welcome and appreciate any suggestions you may have for improvement. For bugs, questions, and discussions please use the GitHub Issues.
Acknowledgments
It extends Flutter’s foundation to provide a ready-to-use, customizable currency formatter widget.While Flutter and intl provide the base, price_text simplifies the process by combining widgets and formatting logic into a single package you can drop into any app.
Contribution
The DashStack team enthusiastically welcomes contributions and project participation! There are a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing new features.
Credits
price_text is owned and maintained by the Dashstack Infotech team (SURAT, INDIA).
Follow us for updates and new releases 🚀.