Summary
flutter analyze flags 4 locations across both apps where a BuildContext is used after an await without a proper mounted guard. This can cause crashes if the widget is unmounted between the async call and the context usage.
Affected Files
patient app
| File |
Line |
Detail |
lib/presentation/result/book_appointment.dart |
55 |
use_build_context_synchronously |
lib/provider/therapist_provider.dart |
65, 69 |
use_build_context_synchronously |
therapist app
| File |
Line |
Detail |
lib/presentation/auth/personal_details_screen.dart |
115, 124 |
use_build_context_synchronously — guarded by an unrelated mounted check |
Steps to Reproduce
cd patient && flutter analyze
cd ../therapist && flutter analyze
Expected Behavior
All context usages after await are guarded by if (!mounted) return or the context reference is captured before the async gap.
Fix
- Add
if (!mounted) return; immediately after each await before accessing context
- In
personal_details_screen.dart: move the mounted check to guard the specific context access (not an unrelated branch)
Summary
flutter analyzeflags 4 locations across both apps where aBuildContextis used after anawaitwithout a propermountedguard. This can cause crashes if the widget is unmounted between the async call and the context usage.Affected Files
patient app
lib/presentation/result/book_appointment.dartuse_build_context_synchronouslylib/provider/therapist_provider.dartuse_build_context_synchronouslytherapist app
lib/presentation/auth/personal_details_screen.dartuse_build_context_synchronously— guarded by an unrelatedmountedcheckSteps to Reproduce
Expected Behavior
All context usages after
awaitare guarded byif (!mounted) returnor the context reference is captured before the async gap.Fix
if (!mounted) return;immediately after eachawaitbefore accessingcontextpersonal_details_screen.dart: move themountedcheck to guard the specific context access (not an unrelated branch)