CustomerProfileNotifier
manage-profile/customer_profile_provider.dart · AsyncNotifier
Overview
AutoDispose AsyncNotifier for the edit/view screens. loadClientInfo on build, refreshClientInfo for pull-to-refresh, updatePersonInfo for edits — all gated by ref.mounted checks to avoid setting state after disposal.
User Flow
- build() returns getClientInfo() — set loading → data | error.
- updatePersonInfo: read userServiceProvider BEFORE setting loading (prevents disposed-ref crash), then POST, then state.data on success.
- Errors rethrow so the calling form can show a SnackBar with the message.
Cases & Edge Cases
- ref.mounted guard prevents the classic 'setState after dispose' crash when the user navigates away mid-update.
- AutoDispose means stale state goes away when ManageProfileScreen pops — re-entry refetches.
- Calling refreshClientInfo immediately after a successful update is redundant — the update response already contains the fresh data.
Code References
- lib/src/features/shared/manage-profile/customer_profile_provider.dart:7 // CustomerProfileNotifier
- lib/src/features/shared/manage-profile/customer_profile_provider.dart:37 // updatePersonInfo (ref.mounted guard)
- lib/src/features/shared/manage-profile/customer_profile_provider.dart:70 // customerProfileServiceProvider (autoDispose)
API Calls
Empty — fill this in later. Open the manifest and add content here.
Notes
userServiceProvider is declared twice (here and in personal_info_provider.dart) — both yield the same UserService instance, no problem in practice.