Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NumberFormat not found flutter

Tags:

flutter

dart

Below code NumberFormat class is not found in 'package:intl/intl.dart' package

code : NumberFormat heart = new NumberFormat("#,###", "en_US");

like image 443
Pradeep Bishnoi Avatar asked May 29 '18 11:05

Pradeep Bishnoi


People also ask

How do I show my number on flutter?

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.

Is Intl part of flutter?

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.

How to add localized text to your flutter application?

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.

How do I format a number in Dart?

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.

What languages does flutter support?

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.


2 Answers

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";
like image 117
Günter Zöchbauer Avatar answered Oct 20 '22 20:10

Günter Zöchbauer


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)

like image 35
Carolina Brito Avatar answered Oct 20 '22 19:10

Carolina Brito