Description
Several screens and dialogs capture context before an await and use it afterwards. While mounted checks are present in most cases, there are inconsistencies where some paths miss the check.
Affected Files
lib/widgets/settle_up_dialog.dart — context used after dialog operations
lib/screens/group_details_screen.dart — _loadData() sets state without mounted guard
lib/screens/bill_detail_screen.dart — _loadData() in initState may complete after dispose
Recommended Fix
Always capture ScaffoldMessenger.of(context) and Navigator.of(context) before the await, then use the captured reference after.
// Before (unsafe)
await someAsyncOp();
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(...);
}
// After (safe)
final messenger = ScaffoldMessenger.of(context);
await someAsyncOp();
if (mounted) {
messenger.showSnackBar(...);
}
Priority
High — can cause crashes on slow devices or flaky networks.
Description
Several screens and dialogs capture
contextbefore anawaitand use it afterwards. Whilemountedchecks are present in most cases, there are inconsistencies where some paths miss the check.Affected Files
lib/widgets/settle_up_dialog.dart— context used after dialog operationslib/screens/group_details_screen.dart—_loadData()sets state without mounted guardlib/screens/bill_detail_screen.dart—_loadData()in initState may complete after disposeRecommended Fix
Always capture
ScaffoldMessenger.of(context)andNavigator.of(context)before theawait, then use the captured reference after.Priority
High — can cause crashes on slow devices or flaky networks.