From fcdc96d944659f7e4f4d38ebbf620e9690f57579 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Thu, 9 Apr 2026 14:42:32 +0300 Subject: [PATCH] no message --- lib/core/app_state.dart | 4 ---- .../my_family/widget/family_cards.dart | 2 +- .../widgets/profile_picture_widget.dart | 18 +++++++++++++++--- lib/widgets/user_avatar_widget.dart | 5 ----- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/core/app_state.dart b/lib/core/app_state.dart index 1b4a5e4d..85fe9cb2 100644 --- a/lib/core/app_state.dart +++ b/lib/core/app_state.dart @@ -94,22 +94,18 @@ class AppState { String? get getProfileImageData => _profileImageData; set setProfileImageData(String? value) { - print('📸 AppState: Setting profile image data - ${value != null && value.isNotEmpty ? "Has data (${value.length} chars)" : "Empty/null"}'); _profileImageData = value; // Persist to cache if (value != null && value.isNotEmpty) { cacheService.saveString(key: _profileImageKey, value: value); - print('💾 AppState: Profile image saved to cache'); } else { cacheService.remove(key: _profileImageKey); - print('🗑️ AppState: Profile image removed from cache'); } } /// Load profile image from cache on app initialization void _loadProfileImageFromCache() { _profileImageData = cacheService.getString(key: _profileImageKey); - print('📂 AppState: Loaded profile image from cache - ${_profileImageData != null && _profileImageData!.isNotEmpty ? "Has data (${_profileImageData!.length} chars)" : "Empty/null"}'); } /// Clear profile image from cache (e.g., on logout) diff --git a/lib/presentation/my_family/widget/family_cards.dart b/lib/presentation/my_family/widget/family_cards.dart index b3081dc1..60ec335a 100644 --- a/lib/presentation/my_family/widget/family_cards.dart +++ b/lib/presentation/my_family/widget/family_cards.dart @@ -312,7 +312,7 @@ class _FamilyCardsState extends State { crossAxisCount: 2, crossAxisSpacing: 10.w, mainAxisSpacing: 10.h, - // childAspectRatio: widget.isShowDetails ? 0.56.h : 0.74.h, + childAspectRatio: widget.isShowDetails ? 0.80.h : 0.80.h, // childAspectRatio: 0.7.h, ), padding: EdgeInsets.only(bottom: 20.h), diff --git a/lib/presentation/profile_settings/widgets/profile_picture_widget.dart b/lib/presentation/profile_settings/widgets/profile_picture_widget.dart index 7cbeb0ea..387907fa 100644 --- a/lib/presentation/profile_settings/widgets/profile_picture_widget.dart +++ b/lib/presentation/profile_settings/widgets/profile_picture_widget.dart @@ -32,12 +32,24 @@ class _ProfilePictureWidgetState extends State { @override void initState() { super.initState(); + // Use addPostFrameCallback to ensure widget is built before loading WidgetsBinding.instance.addPostFrameCallback((_) { - // Sync ViewModel with AppState first + if (!mounted) return; + final profileVm = context.read(); - profileVm.syncProfileImageFromAppState(); - _loadProfileImage(); + // Only sync if AppState has data and ViewModel doesn't + if (_appState.getProfileImageData != null && + _appState.getProfileImageData!.isNotEmpty && + (profileVm.profileImageData == null || profileVm.profileImageData!.isEmpty)) { + profileVm.syncProfileImageFromAppState(); + } + + // Only load if no data exists in both AppState and ViewModel + if ((_appState.getProfileImageData == null || _appState.getProfileImageData!.isEmpty) && + (profileVm.profileImageData == null || profileVm.profileImageData!.isEmpty)) { + _loadProfileImage(); + } }); } diff --git a/lib/widgets/user_avatar_widget.dart b/lib/widgets/user_avatar_widget.dart index 56545a0d..6132401c 100644 --- a/lib/widgets/user_avatar_widget.dart +++ b/lib/widgets/user_avatar_widget.dart @@ -36,11 +36,6 @@ class UserAvatarWidget extends StatelessWidget { // Use custom profile image data if provided, otherwise use AppState data final profileImageData = customProfileImageData ?? appState.getProfileImageData; - // Debug logging - print('🖼️ UserAvatarWidget build - Has profile image: ${profileImageData != null && profileImageData.isNotEmpty}'); - if (profileImageData != null && profileImageData.isNotEmpty) { - print('🖼️ Profile image data length: ${profileImageData.length} characters'); - } // Determine the default image based on gender and age final String defaultImage;