I would like please to turn the code below to be :
Future<List> fetchPrices() async {details in code below}
without having errors.
The code to be changed is here:
Future<void> main(List<String> arguments) async {
Map<String, num> quotes = await Forex.fx(
quoteProvider: QuoteProvider.yahoo,
base: 'USD',
quotes: <String>['EUR', 'JPY']
);
print('Number of quotes retrieved: ${quotes.keys.length}.');
print('Exchange rate USDEUR: ${quotes['USDEUR']}.');
print('Exchange rate USDJPY: ${quotes['USDJPY']}.');
quotes = await Forex.fx(
quoteProvider: QuoteProvider.ecb,
base: 'JPY',
quotes: <String>['EUR', 'USD']
);
print('Number of quotes retrieved: ${quotes.keys.length}.');
print('Exchange rate JPYEUR: ${quotes['JPYEUR']}.');
print('Exchange rate JPYUSD: ${quotes['JPYUSD']}.');
}
According to your code example Forex.fx()
return Map<String, num>
. So you have two options here.
Future<List<String>> fooFunction(List<String> arguments) async {
Map<String, num> quotes = await Forex.fx(
quoteProvider: QuoteProvider.yahoo,
base: 'USD',
quotes: <String>['EUR', 'JPY']
);
return quotes.keys;
}
Future<List<num>> fooFunction(List<String> arguments) async {
Map<String, num> quotes = await Forex.fx(
quoteProvider: QuoteProvider.yahoo,
base: 'USD',
quotes: <String>['EUR', 'JPY']
);
return quotes.values;
}