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