fix conversation detail download audio Navigator null crash#7589
fix conversation detail download audio Navigator null crash#7589krushnarout wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s.dart Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…m widgets.dart" This reverts commit 57404f4.
Greptile SummaryThis PR fixes a
Confidence Score: 4/5Safe to merge — all changes are targeted async-safety guards that eliminate a confirmed production crash and correct nearby context-lifetime mismatches without altering any business logic. All five changes directly address real widget-lifetime bugs that were either causing confirmed crashes or silently using stale contexts after async gaps. The fixes are minimal and localized, and the underlying download/star-toggle logic is unchanged. No files require special attention — the single changed file has well-scoped, straightforward guard corrections. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant DetailPage as ConversationDetailPage
participant Sheet as AudioDownloadProgressSheet
participant Service as AudioDownloadService
User->>DetailPage: tap "Download Audio"
DetailPage->>Sheet: showModalBottomSheet(isDismissible:false)
DetailPage->>Service: downloadAndCombineAudio()
Note over User,Service: Long async operation (network + processing)
alt User navigates away mid-download
User->>DetailPage: pop page
DetailPage-->>Sheet: (sheet also dismissed by Flutter)
end
alt Download succeeds
Service-->>DetailPage: returns File
DetailPage->>DetailPage: sheetContext.mounted?
DetailPage->>Sheet: Navigator.maybeOf(sheetContext)?.pop()
DetailPage->>User: Share.shareXFiles(...)
else No audio available
Service-->>DetailPage: returns null
DetailPage->>DetailPage: sheetContext.mounted?
DetailPage->>Sheet: Navigator.maybeOf(sheetContext)?.pop()
else Error during download
Service-->>DetailPage: throws exception
DetailPage->>DetailPage: sheetContext.mounted?
DetailPage->>Sheet: Navigator.maybeOf(sheetContext)?.pop()
DetailPage->>DetailPage: context.mounted?
DetailPage->>User: ScaffoldMessenger.showSnackBar(error)
end
DetailPage->>DetailPage: "finally: if(mounted) setState(_isDownloadingAudio=false)"
Reviews (1): Last reviewed commit: "Revert "chore remove unused _copyContent..." | Re-trigger Greptile |
kodjima33
left a comment
There was a problem hiding this comment.
Bug fix: replaces unsafe Navigator.of(sheetContext) with Navigator.maybeOf(sheetContext)?.pop() in conversation detail audio download path, plus correct context.mounted guards in adjacent callbacks. Small (21 lines), single file, addresses a real Crashlytics issue.
Crash
_ConversationDetailPageState._downloadAudioError:
FlutterError - Null check operator used on a null valuepackage:omi/pages/conversation_detail/page.dart:584Crashlytics: https://console.firebase.google.com/u/0/project/based-hardware/crashlytics/app/ios:com.friend-app-with-wearable.ios12/issues/9847dad06f42b3d650cb74fa0a169732?time=7d&types=crash&sessionEventKey=2b3db86de2c341d5814d995b3ce760c9_2223656953270793706
Logs:
Fix
Primary crash:
Navigator.of(sheetContext)internally force-unwraps the navigator ancestor. If the page is popped during the long audio download (network + processing), the context is no longer in the tree and the unwrap crashes. Fixed by replacing all threeNavigator.of(sheetContext).pop()calls withNavigator.maybeOf(sheetContext)?.pop(), which safely no-ops when the navigator is gone.Context guard fixes found alongside:
if (mounted)was guardingsheetContext-based Navigator pops — should besheetContext.mountedsincemounted(State) and the sheet's context are unrelatedScaffoldMessenger.of(context)in the catch block was guarded by Statemounted— changed tocontext.mountedsincecontextis the parameterBuildContext, notthis.contextif (!mounted) returnguardedcontext.read<>()andScaffoldMessenger.of(context)— changed tocontext.mountedfor the same reasonshowReviewPromptIfNeeded(context, ...)after two awaits in action item toggle had no mounted guard — addedif (mounted)before the call🤖 Generated with Claude Code