Skip to content

Commit

Permalink
pages/withdrawal_page: fix BuildContexts across async gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
octobocto committed Oct 30, 2023
1 parent d9f986e commit 6a9ade4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/pages/withdrawal_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:stacked/stacked.dart';

// TODO: the legacy testchain GUI uses the term SCO for sidechain BTC. A bit
// confusing? They are bitcoin, after all. Need to find a nice term.
// SBTC?

@RoutePage()
class WithdrawalPage extends StatelessWidget {
Expand Down Expand Up @@ -180,8 +181,13 @@ class WithdrawalPageViewModel extends MultipleFutureViewModel {

final address = withdrawalAddress;

// TODO: i'm sure this linter rule is there for a reason. What's correct here?
// ignore: use_build_context_synchronously
// Because the function is async, the view might disappear/unmount
// by the time it's used. The linter doesn't like that, and wants
// you to check whether the view is mounted before using it
if (!context.mounted) {
return;
}

await showDialog(
context: context,
builder: (context) => AlertDialog(
Expand Down

0 comments on commit 6a9ade4

Please sign in to comment.