Search code examples
flutterdarttextformfield

Thousand separator in flutter


Is there a way to make a thousand separator when typing numbers in a TextFormField in flutter? This is my TextFormField

child: TextFormField(
 decoration: InputDecoration(
     border: const OutlineInputBorder()),
 keyboardType: TextInputType.number,
),

Solution

  • First add intl flutter package

    dependencies:
      intl: ^0.16.1
    

    Now use NumberFormat

     var formatter = new NumberFormat("#,###");
      print(formatter.format(1234)), // this will be: 1,234