fix: change cacheBalance type
This commit is contained in:
parent
aebcbc6bdf
commit
eeb7b03259
|
@ -315,7 +315,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> balanceCache = {};
|
Map<String, double> balanceCache = {};
|
||||||
|
|
||||||
Widget balance(BuildContext context, String address, double size,
|
Widget balance(BuildContext context, String address, double size,
|
||||||
[Color _color = Colors.black]) {
|
[Color _color = Colors.black]) {
|
||||||
|
@ -323,11 +323,12 @@ Widget balance(BuildContext context, String address, double size,
|
||||||
Consumer<SubstrateSdk>(builder: (context, _sdk, _) {
|
Consumer<SubstrateSdk>(builder: (context, _sdk, _) {
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: _sdk.getBalance(address),
|
future: _sdk.getBalance(address),
|
||||||
builder: (BuildContext context, AsyncSnapshot<num?> _balance) {
|
builder: (BuildContext context, AsyncSnapshot<double> _balance) {
|
||||||
if (_balance.connectionState != ConnectionState.done ||
|
if (_balance.connectionState != ConnectionState.done ||
|
||||||
_balance.hasError) {
|
_balance.hasError) {
|
||||||
if (balanceCache[address] != null) {
|
if (balanceCache[address] != null) {
|
||||||
return Text(balanceCache[address]!,
|
return Text(
|
||||||
|
"${balanceCache[address]!.toString()} $currencyName",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: isTall ? size : size * 0.9, color: _color));
|
fontSize: isTall ? size : size * 0.9, color: _color));
|
||||||
} else {
|
} else {
|
||||||
|
@ -341,9 +342,9 @@ Widget balance(BuildContext context, String address, double size,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balanceCache[address] = "${_balance.data.toString()} $currencyName";
|
balanceCache[address] = _balance.data!;
|
||||||
return Text(
|
return Text(
|
||||||
balanceCache[address]!,
|
"${balanceCache[address]!.toString()} $currencyName",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: isTall ? size : size * 0.9,
|
fontSize: isTall ? size : size * 0.9,
|
||||||
color: _color,
|
color: _color,
|
||||||
|
|
|
@ -500,8 +500,7 @@ class WalletOptions extends StatelessWidget {
|
||||||
_hasConsumers.hasError) {
|
_hasConsumers.hasError) {
|
||||||
return const Text('');
|
return const Text('');
|
||||||
}
|
}
|
||||||
final _balance = double.parse(
|
final double _balance = balanceCache[walletProvider.address.text]!;
|
||||||
balanceCache[walletProvider.address.text]!.split(' ')[0]);
|
|
||||||
final bool canDelete = !isDefaultWallet &&
|
final bool canDelete = !isDefaultWallet &&
|
||||||
!_hasConsumers.data! &&
|
!_hasConsumers.data! &&
|
||||||
(_balance > 2 || _balance == 0);
|
(_balance > 2 || _balance == 0);
|
||||||
|
|
|
@ -424,10 +424,9 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
if (_walletViewProvider.payAmount.text != '' &&
|
if (_walletViewProvider.payAmount.text != '' &&
|
||||||
(double.parse(_walletViewProvider.payAmount.text) + 2) <=
|
(double.parse(_walletViewProvider.payAmount.text) + 2) <=
|
||||||
double.parse(
|
(balanceCache[defaultWallet.address] ?? 0) &&
|
||||||
balanceCache[defaultWallet.address]!.split(' ')[0]) &&
|
|
||||||
_walletViewProvider.address != defaultWallet.address) {
|
_walletViewProvider.address != defaultWallet.address) {
|
||||||
if (balanceCache[pubkey] == '0.0 $currencyName' &&
|
if ((balanceCache[pubkey] == 0 || balanceCache[pubkey] == null) &&
|
||||||
double.parse(_walletViewProvider.payAmount.text) < 5) {
|
double.parse(_walletViewProvider.payAmount.text) < 5) {
|
||||||
canValidate = false;
|
canValidate = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -525,7 +524,7 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
future:
|
future:
|
||||||
_sub.getBalance(defaultWallet.address!),
|
_sub.getBalance(defaultWallet.address!),
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context,
|
||||||
AsyncSnapshot<num?> _balance) {
|
AsyncSnapshot<double> _balance) {
|
||||||
if (_balance.connectionState !=
|
if (_balance.connectionState !=
|
||||||
ConnectionState.done ||
|
ConnectionState.done ||
|
||||||
_balance.hasError) {
|
_balance.hasError) {
|
||||||
|
@ -533,8 +532,7 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
defaultWallet.address!] !=
|
defaultWallet.address!] !=
|
||||||
null) {
|
null) {
|
||||||
return Text(
|
return Text(
|
||||||
balanceCache[
|
"${balanceCache[defaultWallet.address!]} $currencyName",
|
||||||
defaultWallet.address!]!,
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
));
|
));
|
||||||
|
@ -550,9 +548,9 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balanceCache[defaultWallet.address!] =
|
balanceCache[defaultWallet.address!] =
|
||||||
"${_balance.data.toString()} $currencyName";
|
_balance.data!;
|
||||||
return Text(
|
return Text(
|
||||||
balanceCache[defaultWallet.address!]!,
|
"${balanceCache[defaultWallet.address!]} $currencyName",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
),
|
),
|
||||||
|
@ -694,7 +692,7 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
Provider.of<WalletOptionsProvider>(context, listen: false);
|
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||||
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
|
|
||||||
bool isAccountExist = balanceCache[pubkey] != '0.0 $currencyName';
|
bool isAccountExist = balanceCache[pubkey] != 0;
|
||||||
|
|
||||||
return Stack(children: <Widget>[
|
return Stack(children: <Widget>[
|
||||||
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: Pay with G1.
|
||||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.8+3
|
version: 0.0.8+5
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
|
|
Loading…
Reference in New Issue