minor fix [skip ci]
OmarHatem committed
Jul 31, 2025 at 20:39 UTC
c67a0f2346a16e1c45da0889e9dec1069f70cedb
2 files changed
+24
-16
lib/buy/buy_quote.dart
+21
-13
@@ -75,10 +75,12 @@ class Quote extends SelectableOption {
75
late FiatCurrency _fiatCurrency;
76
late CryptoCurrency _cryptoCurrency;
77
78
-
78
bool get isSelected => _isSelected;
79
+
80
bool get isBestRate => _isBestRate;
81
+
82
FiatCurrency get fiatCurrency => _fiatCurrency;
83
+
84
CryptoCurrency get cryptoCurrency => _cryptoCurrency;
85
86
@override
@@ -96,15 +98,16 @@ class Quote extends SelectableOption {
98
List<String> get badges => recommendations.map((e) => e.title).toList();
99
100
@override
99
- String get topLeftSubTitle =>
100
- this.rate > 0 ? '1 ${cryptoCurrency.toString()} = ${formatWithCommas(rate.toStringAsFixed(2))} ${fiatCurrency.toString()}' : '';
101
+ String get topLeftSubTitle => this.rate > 0
102
+ ? '1 ${cryptoCurrency.toString()} = ${formatWithCommas(rate.toStringAsFixed(2))} ${fiatCurrency.toString()}'
103
+ : '';
104
105
@override
106
String get bottomLeftSubTitle {
107
if (limits != null) {
108
final min = limits!.min;
109
final max = limits!.max;
107
- return 'min: ${min} ${fiatCurrency.toString()} | max: ${max == double.infinity ? '' : '${max} ${fiatCurrency.toString()}'}';
110
+ return 'min: ${formatWithCommas(min?.toString())} ${fiatCurrency.toString()} | max: ${max == double.infinity ? '' : '${formatWithCommas(max?.toString())} ${fiatCurrency.toString()}'}';
111
}
112
return '';
113
}
@@ -123,9 +126,13 @@ class Quote extends SelectableOption {
126
String get formatedFee => '$feeAmount ${isBuyAction ? fiatCurrency : cryptoCurrency}';
127
128
set setIsSelected(bool isSelected) => _isSelected = isSelected;
129
+
130
set setIsBestRate(bool isBestRate) => _isBestRate = isBestRate;
131
+
132
set setFiatCurrency(FiatCurrency fiatCurrency) => _fiatCurrency = fiatCurrency;
133
+
134
set setCryptoCurrency(CryptoCurrency cryptoCurrency) => _cryptoCurrency = cryptoCurrency;
135
+
136
set setLimits(Limits limits) => this.limits = limits;
137
138
factory Quote.fromOnramperJson(Map<String, dynamic> json, bool isBuyAction,
@@ -185,7 +192,7 @@ class Quote extends SelectableOption {
192
customPaymentMethodType: customPaymentMethodType,
193
quoteId: json['quoteId'] as String? ?? '',
194
recommendations: enumRecommendations,
188
- provider: ProvidersHelper.getProviderByType(ProviderType.onramper)!,
195
+ provider: ProvidersHelper.getProviderByType(ProviderType.onramper),
196
isBuyAction: isBuyAction,
197
limits: Limits(min: minLimit, max: maxLimit),
198
);
@@ -220,7 +227,7 @@ class Quote extends SelectableOption {
227
paymentType: paymentType,
228
recommendations: [],
229
quoteId: json['signature'] as String? ?? '',
223
- provider: ProvidersHelper.getProviderByType(ProviderType.moonpay)!,
230
+ provider: ProvidersHelper.getProviderByType(ProviderType.moonpay),
231
isBuyAction: isBuyAction,
232
limits: Limits(min: minLimit, max: maxLimit),
233
);
@@ -245,7 +252,7 @@ class Quote extends SelectableOption {
252
payout: _toDouble(json['payout']) ?? 0.0,
253
paymentType: paymentType,
254
recommendations: [ProviderRecommendation.lowKyc],
248
- provider: ProvidersHelper.getProviderByType(ProviderType.dfx)!,
255
+ provider: ProvidersHelper.getProviderByType(ProviderType.dfx),
256
isBuyAction: isBuyAction,
257
limits: Limits(min: minVolume, max: maxVolume),
258
);
@@ -267,7 +274,7 @@ class Quote extends SelectableOption {
274
payout: _toDouble(json['cryptoAmount']) ?? 0.0,
275
paymentType: paymentType,
276
recommendations: [],
270
- provider: ProvidersHelper.getProviderByType(ProviderType.robinhood)!,
277
+ provider: ProvidersHelper.getProviderByType(ProviderType.robinhood),
278
isBuyAction: isBuyAction,
279
limits: Limits(min: 0.0, max: double.infinity),
280
);
@@ -283,7 +290,7 @@ class Quote extends SelectableOption {
290
payout: quotes['payout'] as double? ?? 0.0,
291
paymentType: paymentType,
292
recommendations: [],
286
- provider: ProvidersHelper.getProviderByType(ProviderType.meld)!,
293
+ provider: ProvidersHelper.getProviderByType(ProviderType.meld),
294
isBuyAction: isBuyAction,
295
limits: Limits(min: 0.0, max: double.infinity),
296
);
@@ -292,7 +299,7 @@ class Quote extends SelectableOption {
299
factory Quote.fromKryptonimJson(
300
Map<String, dynamic> json, bool isBuyAction, PaymentType paymentType) {
301
final fees = json['fees'] as Map<String, dynamic>;
295
- final rate = _toDouble(json['rate']) ?? 0.0;
302
+ // final rate = _toDouble(json['rate']) ?? 0.0;
303
final limits = json['limits'] as Map<String, dynamic>;
304
final minLimit = _toDouble(limits['min_amount']) ?? 0.0;
305
final maxLimit = _toDouble(limits['max_amount']) ?? double.infinity;
@@ -300,14 +307,14 @@ class Quote extends SelectableOption {
307
final amount = _toDouble(json['amount']) ?? 0.0;
308
final calculatedRate = amount / convertedAmount;
309
return Quote(
303
- rate: calculatedRate,
310
+ rate: calculatedRate,
311
feeAmount: _toDouble(fees['totalFee']) ?? 0.0,
312
networkFee: _toDouble(fees['network_fee']) ?? 0.0,
313
transactionFee: _toDouble(fees['operation_fee']) ?? 0.0,
314
payout: _toDouble(json['amount']) ?? 0.0,
315
paymentType: paymentType,
316
recommendations: [],
310
- provider: ProvidersHelper.getProviderByType(ProviderType.kriptonim)!,
317
+ provider: ProvidersHelper.getProviderByType(ProviderType.kriptonim),
318
isBuyAction: isBuyAction,
319
limits: Limits(min: minLimit, max: maxLimit));
320
}
@@ -324,5 +331,6 @@ class Quote extends SelectableOption {
331
}
332
333
@override
327
- String toString() => 'Quote: rate: $rate, feeAmount: $feeAmount, networkFee: $networkFee, transactionFee: $transactionFee, payout: $payout, paymentType: $paymentType, provider: $provider, quoteId: $quoteId, recommendations: $recommendations, isBuyAction: $isBuyAction, rampId: $rampId, rampName: $rampName, rampIconPath: $rampIconPath, [limits: min: ${limits?.min}, max: ${limits?.max}]';
334
+ String toString() =>
335
+ 'Quote: rate: $rate, feeAmount: $feeAmount, networkFee: $networkFee, transactionFee: $transactionFee, payout: $payout, paymentType: $paymentType, provider: $provider, quoteId: $quoteId, recommendations: $recommendations, isBuyAction: $isBuyAction, rampId: $rampId, rampName: $rampName, rampIconPath: $rampIconPath, [limits: min: ${limits?.min}, max: ${limits?.max}]';
336
}
lib/entities/calculate_fiat_amount.dart
+3
-3
@@ -29,10 +29,10 @@ String calculateFiatAmount({double? price, String? cryptoAmount}) {
29
return result > 0.01 ? formatted : '< 0.01';
30
}
31
32
-String formatWithCommas(String number) {
33
- if (number.isEmpty) return number;
32
+String formatWithCommas(String? number) {
33
+ if (number?.isEmpty ?? true) return '';
34
35
- final parts = number.split('.');
35
+ final parts = number!.split('.');
36
final integerPart = parts[0];
37
final decimalPart = parts.length > 1 ? parts[1] : '';
38