Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Flutter provides the NumberFormat class that can be used to convert a double with low value into currency.

Here is an example code:

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

class CurrencyConverter extends StatelessWidget {
  final double value;

  CurrencyConverter({@required this.value});

  @override
  Widget build(BuildContext context) {
    return Text(
      '${NumberFormat.currency(locale: 'en_US', symbol: '\$').format(value)}',
      style: TextStyle(fontSize: 16.0),
    );
  }
}

In the Text widget, the NumberFormat class is used with the currency method to format the double value into currency. The locale parameter is used to set the currency format to US dollars and the symbol parameter is used to set the currency symbol to $.

This widget can be used like this:

CurrencyConverter(value: 10.50)

This will display $10.50 on the screen.