no message

pull/224/head
Sultan khan 3 days ago
parent 21ae30a8cc
commit fcdc96d944

@ -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)

@ -312,7 +312,7 @@ class _FamilyCardsState extends State<FamilyCards> {
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),

@ -32,12 +32,24 @@ class _ProfilePictureWidgetState extends State<ProfilePictureWidget> {
@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<ProfileSettingsViewModel>();
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();
}
});
}

@ -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;

Loading…
Cancel
Save