Ad
Flutter NumberFormat Format Without Changing Language
I am trying to format the number according to selected currency without translating it. For example the
Text(NumberFormat.simpleCurrency(
locale: 'bn_BN',
).format(123456.78));
outputs
১,২৩,৪৫৬.৭৮৳
I want the format but not on the locales language. How do i get it to look like this instead -
1,23,456.78 BDT or 1,23,456.78 ৳
Is there a way to achieve this
P.S. I just need the thousands seperator or grouping to be what the currency default is for example BDT grouping is XX,XX,XXX first comma after thousand then comma after each 2 digits. This is something the NumberFormat does on its own but unfortunately only when u pass in locale.
Ad
Answer
You can define a custom NumberFormatter somewhere in your code (assuming that you will use it in different parts of your application) and format() numbers using it:
final myFormatter = new NumberFormat.currency(
name: 'BDT',
decimalDigits: 2,
customPattern: '#,##,##0.00 \u00A4',
);
Text(myFormatter.format(12345678.01)),
This will result in: 1,23,45,678.01 BDT
Ad
source: stackoverflow.com
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?
Ad