dart display number in digit grouping number format
dart display number in digit grouping number format

Hi Guys, Welcome to Proto Coders Point. In this dart tutorial will learn how to display large number by adding commas to the numbers, so basically will do Number formatting in digit grouping form.

For Example: 100000 will be displayed as 1,00,000.

In Dart we have a class i.e.

Dart number format - display number... x
Dart number format - display number by adding comma’s.
NumberFormat which comes from flutter intl package.

Dart NumberFormat class

In Dart a number format class will help us by it’s ability to format number in a locale format.

From intl numberformat we will use decimalPattern to display number in Digit Grouping like this 1,00,000


Install intl package

If Dart Project:

dart pub add intl

In Flutter Project:

flutter pub add intl

Now import intl.dart where require

import 'package:intl/intl.dart';

Flutter Dart – Add commas digit grouping to large number

Example:

import 'package:intl/intl.dart';

void main() {
   var longnum = 100500064965849;
   var num = 10000000;
   var longnum2 = 87965100421;

  NumberFormat myFormat = NumberFormat.decimalPattern('en_us');
  print(myFormat.format(longnum));
  print(myFormat.format(num));
  print(myFormat.format(longnum2));
}

output

dart digit grouping