money2
Search…
Money.parse
Money.parse parses a string containing a monetary value.
Money.fromInt is faster if you already have the value represented as an integer in minor units.
The simplest variant of Money.parse relies on the default pattern of the passed currency.
1
import 'package:money2/money2.dart';
2
final Currency usd = Currency.create('USD', 2);
3
final Money amount = Money.parse(r'$10.25', usd);
Copied!
You can also pass an explicit pattern.
1
import 'money2.dart';
2
final Currency usd = Currency.create('USD', 2);
3
final Money amount = Money.parse(r'$10.25', usd, 'S0.00');
Copied!
Copy link