Below code NumberFormat class is not found in 'package:intl/intl.dart' package
code : NumberFormat heart = new NumberFormat("#,###", "en_US");
Steps to show numeric input keyboard in FlutterStep 1: Add TextField widget to your dart file. Step 2: Add keyboardType parameter and assign the TextInputType. number. Step 3: Add inputFormatters parameter and assign the [FilteringTextInputFormatter.
The Flutter team cannot make further progress on this issue until the original reporter responds. I can finally reproduce the issue with your Intl.defaultLocale = 'fr';, intl isn't part of Flutter, please file an issue on their dedicated GitHub as this would reproduce even in a regular dart project using intl without Flutter.
Once the flutter_localizations package is added, use the following instructions to add localized text to your application. Add the intl package to the pubspec.yaml file: Also, in the pubspec.yaml file, enable the generate flag. This is added to the section of the pubspec that is specific to Flutter, and usually comes later in the pubspec file.
Dart - Formatting Currency with NumberFormat. Posted on 02 Nov 2019 by Ivan Andrianto. If you have a number and you want to format it to currency of any locale, Dart makes it easy for us to do it by using NumberFormat class. Currently, Dart already supports hundreds of locales, listed at the bottom of this tutorial.
Although the flutter_localizations library currently supports 78 languages and language variants, only English language translations are available by default. It’s up to the developer to decide exactly which languages to support. The MaterialApp supportedLocales parameter limits locale changes.
Add intl
to your pubspec.yaml
dependencies:
intl: "^0.16.1"
Check for latest version at https://pub.dev/packages/intl
and then import following:
import "package:intl/intl.dart";
your code should be: NumberFormat heart = new NumberFormat("#.###", "en_US");
(If you imported correctly, as comment above, you should put a point instead of a comma)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With