Flutter upgrade

This commit is contained in:
M
2022-10-12 13:09:57 -04:00
parent c921ad890a
commit 1beb18b045
505 changed files with 6657 additions and 5875 deletions
@@ -8,9 +8,8 @@ part 'buy_amount_view_model.g.dart';
class BuyAmountViewModel = BuyAmountViewModelBase with _$BuyAmountViewModel;
abstract class BuyAmountViewModelBase with Store {
BuyAmountViewModelBase() {
amount = '';
BuyAmountViewModelBase()
: amount = '' {
int selectedIndex = FiatCurrency.currenciesAvailableToBuyWith
.indexOf(getIt.get<SettingsStore>().fiatCurrency);
@@ -25,15 +24,15 @@ abstract class BuyAmountViewModelBase with Store {
String amount;
@observable
FiatCurrency fiatCurrency;
late FiatCurrency fiatCurrency;
@computed
double get doubleAmount {
double _amount;
try {
_amount = double.parse(amount.replaceAll(',', '.')) ?? 0.0;
} catch (e) {
_amount = double.parse(amount.replaceAll(',', '.'));
} catch (_) {
_amount = 0.0;
}
+2 -2
View File
@@ -4,7 +4,7 @@ import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/view_model/buy/buy_amount_view_model.dart';
class BuyItem {
BuyItem({this.provider, this.buyAmountViewModel});
BuyItem({required this.provider, required this.buyAmountViewModel});
final BuyProvider provider;
final BuyAmountViewModel buyAmountViewModel;
@@ -18,7 +18,7 @@ class BuyItem {
try {
_buyAmount = await provider
.calculateAmount(amount?.toString(), fiatCurrency.title);
.calculateAmount(amount?.toString() ?? '', fiatCurrency.title);
} catch (e) {
_buyAmount = BuyAmount(sourceAmount: 0.0, destAmount: 0.0);
print(e.toString());
+8 -9
View File
@@ -20,13 +20,12 @@ class BuyViewModel = BuyViewModelBase with _$BuyViewModel;
abstract class BuyViewModelBase with Store {
BuyViewModelBase(this.ordersSource, this.ordersStore, this.settingsStore,
this.buyAmountViewModel, {@required this.wallet}) {
this.buyAmountViewModel, {required this.wallet})
: isRunning = false,
isDisabled = true,
isShowProviderButtons = false,
items = <BuyItem>[] {
_fetchBuyItems();
isRunning = false;
isDisabled = true;
isShowProviderButtons = false;
}
final Box<Order> ordersSource;
@@ -36,7 +35,7 @@ abstract class BuyViewModelBase with Store {
final WalletBase wallet;
@observable
BuyProvider selectedProvider;
BuyProvider? selectedProvider;
@observable
List<BuyItem> items;
@@ -64,7 +63,7 @@ abstract class BuyViewModelBase with Store {
try {
_url = await selectedProvider
?.requestUrl(doubleAmount?.toString(), fiatCurrency.title);
!.requestUrl(doubleAmount.toString(), fiatCurrency.title);
} catch (e) {
print(e.toString());
}
@@ -74,7 +73,7 @@ abstract class BuyViewModelBase with Store {
Future<void> saveOrder(String orderId) async {
try {
final order = await selectedProvider?.findOrderById(orderId);
final order = await selectedProvider!.findOrderById(orderId);
order.from = fiatCurrency.title;
order.to = cryptoCurrency.title;
await ordersSource.add(order);