paisa.dart
A simple package to converts currencies for Dart and Flutter.
Installation
In your pubspec.yaml
:
dependencies:
paisa: ^0.0.6
Usage
void main(List<String> args) async {
// Converts USD to INR
final convertedPaisa = await CurrencyConvertor.convert(
from: Currency.USD,
to: Currency.INR,
amount: 100,
);
final convertedStringPaisa = await CurrencyConvertor.convertFromString(
from: 'USD',
to: 'INR',
amount: 100,
);
print(convertedPaisa.convertedAmount); // 8224.3079
print(convertedStringPaisa.convertedAmount); // 8224.3079
// Get exchange rate for USD to INR
final rate = await CurrencyConvertor.rate(Currency.USD, Currency.INR);
final rateFromString = await CurrencyConvertor.rateFromString('USD', 'INR');
final rateFromCountryCode = await CurrencyConvertor.rateFromCountryCode(from: 'US', to: 'IN');
print('Rate for USD -> INR: ${rate.rate}'); // Rate for USD -> INR: 82.243079
print('Rate for USD -> INR [From String]: ${rateFromString.rate}'); // Rate for USD -> INR [From String]: 82.243079
print('Rate for US -> IN Currency: ${rateFromCountryCode.rate}'); // Rate for US -> IN Currency: 82.243079
}
Note
This library uses exchangerate-api for getting the conversion rates and can be considered a unoffical wrapper for exchangerate-api's Open API.
The library handles the conversion of Currency Code to ISO 4217 Three Letter Currency Code, unless you choose to use convertFromString()
or rateFromString()
According to exchangerate-api the conversion rates are refreshed every 24 hours.
If you would like to know about rate limiting and all of the supported and unsupported currencies, Please checkout Supported Currencies Documentation
Features and bugs
Please file feature requests and bugs at the issue tracker.
Contributions to this repository are welcome.