Skip to content

Commit 3f72ef3

Browse files
committed
action_sheet: Fix straggler use of potentially-dead sheet context
And add a bit of docs clarifying the expected practice.
1 parent 6b127bf commit 3f72ef3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/widgets/action_sheet.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ abstract class MessageActionSheetMenuItemButton extends StatelessWidget {
9999

100100
IconData get icon;
101101
String label(ZulipLocalizations zulipLocalizations);
102+
103+
/// Called when the button is pressed.
104+
///
105+
/// Generally this method's implementation should begin by dismissing the
106+
/// action sheet with [NavigatorState.pop].
107+
/// After that step, the given `context` may no longer be mounted;
108+
/// operations that need a [BuildContext] should typically use [pageContext].
102109
void onPressed(BuildContext context);
103110

104111
final Message message;
@@ -200,7 +207,7 @@ class AddThumbsUpButton extends MessageActionSheetMenuItemButton {
200207
default:
201208
}
202209

203-
showErrorDialog(context: context,
210+
showErrorDialog(context: pageContext,
204211
title: 'Adding reaction failed', message: errorMessage);
205212
}
206213
}

0 commit comments

Comments
 (0)