fix: bad cache on balances

This commit is contained in:
poka 2022-05-24 18:31:41 +02:00
parent 14f784fdc9
commit 04ffabf052
3 changed files with 25 additions and 15 deletions

View File

@ -285,8 +285,7 @@ class WalletOptionsProvider with ChangeNotifier {
} }
} }
// Map<String, String> balanceCache = {}; Map<String, String> balanceCache = {};
String balanceCache = '';
Widget balance(BuildContext context, String address, double size) { Widget balance(BuildContext context, String address, double size) {
return Column(children: <Widget>[ return Column(children: <Widget>[
@ -296,14 +295,25 @@ Widget balance(BuildContext context, String address, double size) {
builder: (BuildContext context, AsyncSnapshot<num?> _balance) { builder: (BuildContext context, AsyncSnapshot<num?> _balance) {
if (_balance.connectionState != ConnectionState.done || if (_balance.connectionState != ConnectionState.done ||
_balance.hasError) { _balance.hasError) {
return Text(balanceCache, if (balanceCache[address] != null) {
style: TextStyle( return Text(balanceCache[address]!,
fontSize: isTall ? size : size * 0.9, style: TextStyle(
)); fontSize: isTall ? size : size * 0.9,
));
} else {
return SizedBox(
height: 15,
width: 15,
child: CircularProgressIndicator(
color: orangeC,
strokeWidth: 2,
),
);
}
} }
balanceCache = "${_balance.data.toString()} $currencyName"; balanceCache[address] = "${_balance.data.toString()} $currencyName";
return Text( return Text(
balanceCache, balanceCache[address]!,
style: TextStyle( style: TextStyle(
fontSize: isTall ? size : 18, fontSize: isTall ? size : 18,
), ),

View File

@ -140,7 +140,7 @@ packages:
name: built_value name: built_value
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "8.3.0" version: "8.3.2"
carousel_slider: carousel_slider:
dependency: "direct main" dependency: "direct main"
description: description:
@ -259,7 +259,7 @@ packages:
name: cross_file name: cross_file
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.3" version: "0.3.3+1"
crypto: crypto:
dependency: "direct main" dependency: "direct main"
description: description:
@ -431,7 +431,7 @@ packages:
name: get name: get
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.6.3" version: "4.6.5"
get_storage: get_storage:
dependency: transitive dependency: transitive
description: description:
@ -636,7 +636,7 @@ packages:
name: infinite_scroll_pagination name: infinite_scroll_pagination
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.1.0" version: "3.2.0"
integration_test: integration_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -999,7 +999,7 @@ packages:
description: description:
path: printing path: printing
ref: HEAD ref: HEAD
resolved-ref: "95bbc1f33b7cb45f7a4b98088b96bc541fefc495" resolved-ref: "96fe6ef3c1ee702a86dd311b3feebdb1f7491cd6"
url: "https://github.com/DavBfr/dart_pdf.git" url: "https://github.com/DavBfr/dart_pdf.git"
source: git source: git
version: "5.9.1" version: "5.9.1"
@ -1016,7 +1016,7 @@ packages:
name: provider name: provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.2" version: "6.0.3"
pub_semver: pub_semver:
dependency: transitive dependency: transitive
description: description:

View File

@ -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.5+3 version: 0.0.6+2
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'