I want to know about NumberFormat.currency constructor in flutter don't know how to implement please guide me

Viewed 5004

I want to know about NumberFormat.currency constructor in flutter.

I don't know how to implement please guide me, thank you.

class CurrencyInputFormatter extends TextInputFormatter{

  @override
  TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
    // TODO: implement formatEditUpdate
    if(newValue.selection.baseOffset == 0){
      print(true);
      return newValue;
    }
    double value = double.parse(newValue.text);
    final formatter  = new NumberFormat.currency();
    String newText = formatter.format(value/100);
    return newValue.copyWith(text: newText,
        selection: new TextSelection.collapsed(offset: newText.length));
  }

}
2 Answers
final formatter = NumberFormat.currency(locale: 'en_US',name: 'EUR');

Here is the library you can use for the NumberFormat.currency()

import 'package:intl/intl.dart';

final formatCurrency = new NumberFormat.simpleCurrency();
Related