Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: (balance) 🐛 fixed multiple balance load bug #217

Merged
merged 12 commits into from
Feb 23, 2022
17 changes: 15 additions & 2 deletions starport_template/lib/pages/assets_portfolio_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,21 @@ import 'package:starport_template/widgets/starport_button_bar.dart';
import 'package:transaction_signing_gateway/model/wallet_public_info.dart';

class AssetsPortfolioPage extends StatefulWidget {
const AssetsPortfolioPage({Key? key}) : super(key: key);
const AssetsPortfolioPage({
this.shouldFetchBalances = false,
Key? key,
}) : super(key: key);

final bool shouldFetchBalances;

@override
State<AssetsPortfolioPage> createState() => _AssetsPortfolioPageState();

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<bool>('shouldFetchBalances', shouldFetchBalances));
}
}

class _AssetsPortfolioPageState extends State<AssetsPortfolioPage> {
Expand Down Expand Up @@ -101,7 +112,9 @@ class _AssetsPortfolioPageState extends State<AssetsPortfolioPage> {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => const TransactionHistoryPage()));

Future _fetchWalletBalances() async {
await StarportApp.walletsStore.getBalances(selectedWallet.publicAddress);
if (widget.shouldFetchBalances == true) {
Zfinix marked this conversation as resolved.
Show resolved Hide resolved
await StarportApp.walletsStore.getBalances(selectedWallet.publicAddress);
}
}

Future<void> _onTapDropDown() async {
Expand Down
4 changes: 3 additions & 1 deletion starport_template/lib/pages/create_wallet_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ class _CreateWalletPageState extends State<CreateWalletPage> {
);
if (mounted) {
await Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const AssetsPortfolioPage()),
MaterialPageRoute(
builder: (_) => const AssetsPortfolioPage(),
),
(route) => false,
);
}
Expand Down
4 changes: 3 additions & 1 deletion starport_template/lib/pages/import_wallet_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ class _ImportWalletPageState extends State<ImportWalletPage> {
_showImportErrorDialog();
} else if (mounted) {
await Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const AssetsPortfolioPage()),
MaterialPageRoute(
builder: (_) => const AssetsPortfolioPage(),
),
(route) => false,
);
}
Expand Down
4 changes: 3 additions & 1 deletion starport_template/lib/pages/sign_transaction_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ class _SignTransactionPageState extends State<SignTransactionPage> {
height: MediaQuery.of(context).size.height / 2.24,
child: AssetsTransferSheet(
onTapDone: () => Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const AssetsPortfolioPage()),
MaterialPageRoute(
builder: (_) => const AssetsPortfolioPage(shouldFetchBalances: true),
),
(route) => false,
),
),
Expand Down