mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
added edge case Logging
This commit is contained in:
parent
88af88740b
commit
9276809e28
1 changed files with 90 additions and 79 deletions
|
@ -2,6 +2,7 @@ import 'package:decimal/decimal.dart';
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:stackwallet/models/exchange/change_now/currency.dart';
|
||||
import 'package:stackwallet/services/change_now/change_now.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
||||
class ExchangeFormState extends ChangeNotifier {
|
||||
Decimal? _fromAmount;
|
||||
|
@ -57,6 +58,7 @@ class ExchangeFormState extends ChangeNotifier {
|
|||
_toAmount == null ? "-" : _toAmount!.toStringAsFixed(8);
|
||||
|
||||
Future<void> updateTo(Currency to, bool shouldNotifyListeners) async {
|
||||
try {
|
||||
_to = to;
|
||||
if (_from == null) {
|
||||
rate = null;
|
||||
|
@ -76,15 +78,16 @@ class ExchangeFormState extends ChangeNotifier {
|
|||
amt = await getStandardEstimatedToAmount(
|
||||
fromAmount: _minFromAmount!, from: _from!, to: _to!);
|
||||
if (amt != null) {
|
||||
rate =
|
||||
(amt / _minFromAmount!).toDecimal(scaleOnInfinitePrecision: 12);
|
||||
rate = (amt / _minFromAmount!)
|
||||
.toDecimal(scaleOnInfinitePrecision: 12);
|
||||
}
|
||||
debugPrint("A");
|
||||
} else {
|
||||
amt = await getStandardEstimatedToAmount(
|
||||
fromAmount: _fromAmount!, from: _from!, to: _to!);
|
||||
if (amt != null) {
|
||||
rate = (amt / _fromAmount!).toDecimal(scaleOnInfinitePrecision: 12);
|
||||
rate =
|
||||
(amt / _fromAmount!).toDecimal(scaleOnInfinitePrecision: 12);
|
||||
}
|
||||
debugPrint("B");
|
||||
}
|
||||
|
@ -111,9 +114,13 @@ class ExchangeFormState extends ChangeNotifier {
|
|||
if (shouldNotifyListeners) {
|
||||
notifyListeners();
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e\n$s", level: LogLevel.Fatal);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateFrom(Currency from, bool shouldNotifyListeners) async {
|
||||
try {
|
||||
_from = from;
|
||||
|
||||
if (_to == null) {
|
||||
|
@ -133,14 +140,15 @@ class ExchangeFormState extends ChangeNotifier {
|
|||
amt = await getStandardEstimatedToAmount(
|
||||
fromAmount: _minFromAmount!, from: _from!, to: _to!);
|
||||
if (amt != null) {
|
||||
rate =
|
||||
(amt / _minFromAmount!).toDecimal(scaleOnInfinitePrecision: 12);
|
||||
rate = (amt / _minFromAmount!)
|
||||
.toDecimal(scaleOnInfinitePrecision: 12);
|
||||
}
|
||||
} else {
|
||||
amt = await getStandardEstimatedToAmount(
|
||||
fromAmount: _fromAmount!, from: _from!, to: _to!);
|
||||
if (amt != null) {
|
||||
rate = (amt / _fromAmount!).toDecimal(scaleOnInfinitePrecision: 12);
|
||||
rate =
|
||||
(amt / _fromAmount!).toDecimal(scaleOnInfinitePrecision: 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +171,9 @@ class ExchangeFormState extends ChangeNotifier {
|
|||
if (shouldNotifyListeners) {
|
||||
notifyListeners();
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("$e\n$s", level: LogLevel.Fatal);
|
||||
}
|
||||
}
|
||||
|
||||
String get rateDisplayString {
|
||||
|
|
Loading…
Reference in a new issue