From fcfcc3e1271c5fca92adb7956909cc8d07c6c0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6sche?= Date: Thu, 29 Jan 2026 00:55:11 +0100 Subject: [PATCH] Delay showing profile update messages until after the build cycle to ensure proper UI updates --- .../lib/widgets/account_settings_dialog.dart | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/b0esche_cloud/lib/widgets/account_settings_dialog.dart b/b0esche_cloud/lib/widgets/account_settings_dialog.dart index 518e76b..af0a68e 100644 --- a/b0esche_cloud/lib/widgets/account_settings_dialog.dart +++ b/b0esche_cloud/lib/widgets/account_settings_dialog.dart @@ -125,15 +125,25 @@ class _AccountSettingsDialogState extends State { // Update auth state context.read().add(UpdateUserProfile(updatedUser)); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Profile updated successfully')), - ); + // Show success message after the build cycle + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Profile updated successfully')), + ); + } + }); } } catch (e) { if (mounted) { - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text('Failed to update profile: $e'))); + // Show error message after the build cycle + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Failed to update profile: $e')), + ); + } + }); } } finally { setState(() => _isLoading = false);