style: apply dart format across project
This commit is contained in:
@@ -75,9 +75,10 @@ class ExchangeRateService {
|
||||
}
|
||||
|
||||
/// USD 금액을 지정된 통화로 변환합니다.
|
||||
Future<double?> convertUsdToTarget(double usdAmount, String targetCurrency) async {
|
||||
Future<double?> convertUsdToTarget(
|
||||
double usdAmount, String targetCurrency) async {
|
||||
await _fetchAllRatesIfNeeded();
|
||||
|
||||
|
||||
switch (targetCurrency) {
|
||||
case 'KRW':
|
||||
final rate = _usdToKrwRate ?? DEFAULT_USD_TO_KRW_RATE;
|
||||
@@ -96,9 +97,10 @@ class ExchangeRateService {
|
||||
}
|
||||
|
||||
/// 지정된 통화를 USD로 변환합니다.
|
||||
Future<double?> convertTargetToUsd(double amount, String sourceCurrency) async {
|
||||
Future<double?> convertTargetToUsd(
|
||||
double amount, String sourceCurrency) async {
|
||||
await _fetchAllRatesIfNeeded();
|
||||
|
||||
|
||||
switch (sourceCurrency) {
|
||||
case 'KRW':
|
||||
final rate = _usdToKrwRate ?? DEFAULT_USD_TO_KRW_RATE;
|
||||
@@ -118,25 +120,22 @@ class ExchangeRateService {
|
||||
|
||||
/// 두 통화 간 변환을 수행합니다. (USD를 거쳐서 변환)
|
||||
Future<double?> convertBetweenCurrencies(
|
||||
double amount,
|
||||
String fromCurrency,
|
||||
String toCurrency
|
||||
) async {
|
||||
double amount, String fromCurrency, String toCurrency) async {
|
||||
if (fromCurrency == toCurrency) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
// fromCurrency → USD → toCurrency
|
||||
double? usdAmount;
|
||||
|
||||
|
||||
if (fromCurrency == 'USD') {
|
||||
usdAmount = amount;
|
||||
} else {
|
||||
usdAmount = await convertTargetToUsd(amount, fromCurrency);
|
||||
}
|
||||
|
||||
|
||||
if (usdAmount == null) return null;
|
||||
|
||||
|
||||
if (toCurrency == 'USD') {
|
||||
return usdAmount;
|
||||
} else {
|
||||
@@ -161,7 +160,7 @@ class ExchangeRateService {
|
||||
/// 언어별 환율 정보를 포맷팅하여 반환합니다.
|
||||
Future<String> getFormattedExchangeRateInfoForLocale(String locale) async {
|
||||
await _fetchAllRatesIfNeeded();
|
||||
|
||||
|
||||
switch (locale) {
|
||||
case 'ko':
|
||||
final rate = _usdToKrwRate ?? DEFAULT_USD_TO_KRW_RATE;
|
||||
@@ -204,12 +203,13 @@ class ExchangeRateService {
|
||||
}
|
||||
|
||||
/// USD 금액을 지정된 언어의 기본 통화로 변환하여 포맷팅된 문자열로 반환합니다.
|
||||
Future<String> getFormattedAmountForLocale(double usdAmount, String locale) async {
|
||||
Future<String> getFormattedAmountForLocale(
|
||||
double usdAmount, String locale) async {
|
||||
String targetCurrency;
|
||||
String localeCode;
|
||||
String symbol;
|
||||
int decimalDigits;
|
||||
|
||||
|
||||
switch (locale) {
|
||||
case 'ko':
|
||||
targetCurrency = 'KRW';
|
||||
@@ -232,7 +232,7 @@ class ExchangeRateService {
|
||||
default:
|
||||
return '\$$usdAmount';
|
||||
}
|
||||
|
||||
|
||||
final convertedAmount = await convertUsdToTarget(usdAmount, targetCurrency);
|
||||
if (convertedAmount != null) {
|
||||
final formattedAmount = NumberFormat.currency(
|
||||
|
||||
Reference in New Issue
Block a user