Project lint checked and step added to config.yml

This commit is contained in:
2022-10-02 17:43:52 +01:00
parent e07e10079e
commit 8100f0b879
26 changed files with 71 additions and 63 deletions

View File

@@ -0,0 +1,46 @@
import 'dart:io';
import 'package:easy_cc_flutter/Utils/currency_utils.dart';
import 'package:easy_cc_flutter/data/model/currency.dart';
import 'package:easy_cc_flutter/data/prefs/currency_pair.dart';
import '../../locator.dart';
import '../../main.dart';
import '../network/backup_currency_api.dart';
import '../network/currency_api.dart';
import '../network/safe_api_call.dart';
import '../prefs/preference_provider.dart';
import 'repository.dart';
class RepositoryImpl extends Repository with SafeApiCall {
final PreferenceProvider _prefs = locator<PreferenceProvider>();
final CurrencyApi _api = locator<CurrencyApi>();
final BackupCurrencyApi _backupApi = locator<BackupCurrencyApi>();
@override
CurrencyPair getConversionPair() {
return _prefs.getConversionPair();
}
@override
Future<void> setConversionPair(String fromCurrency, String toCurrency) {
return _prefs.saveConversionPair(fromCurrency, toCurrency);
}
@override
Future<Currency> getConversationRateFromApi(String fromCurrency, String toCurrency) async {
String from = fromCurrency.getCurrencyCode();
String to = toCurrency.getCurrencyCode();
String currency = "${from}_$to";
try {
ResponseObject responseObject = await getDataFromApiCall(_api.getConversion(currency));
return responseObject.convert();
} on HttpException catch(error) {
logger.e(error);
CurrencyResponse responseObject = await getDataFromApiCall(_backupApi.getCurrencyRate(from, to));
return responseObject.convert();
}
}
}