Skip to content

Commit

Permalink
fix: block user dialog
Browse files Browse the repository at this point in the history
The bug here was quite simple: the `pop` callback was being invoked with the parent's `context`.

Flutter uses the navigation stack to know what to `pop`. Whenever we invoke it via `Navigator.pop(context)`, it uses the `context` to derive where the method is being invoked and act accordingly.

By using the wrong `context`, the dialog was not being disposed of, and neither was it returning the value of the confirmation, effectively meaning the user wasn't being blocked.
  • Loading branch information
brenodt authored and MathJud committed Apr 8, 2024
1 parent 6f0e9fe commit 2bcb906
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions qaul_ui/lib/screens/home/user_details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ class UserDetailsScreen extends HookConsumerWidget {
BuildContext context, {
required String description,
}) async {
void pop({bool res = false}) => Navigator.pop(context, res);

return await showDialog(
context: context,
builder: (c) {
builder: (context) {
final l10n = AppLocalizations.of(context)!;

return QaulDialog(
Expand All @@ -177,9 +175,9 @@ class UserDetailsScreen extends HookConsumerWidget {
],
),
button1Label: l10n.okDialogButton,
onButton1Pressed: () => pop(res: true),
onButton1Pressed: () => Navigator.pop(context, true),
button2Label: l10n.cancelDialogButton,
onButton2Pressed: pop,
onButton2Pressed: () => Navigator.pop(context),
);
},
);
Expand Down

0 comments on commit 2bcb906

Please sign in to comment.