Delay showing profile update messages until after the build cycle to ensure proper UI updates

This commit is contained in:
Leon Bösche
2026-01-29 00:55:11 +01:00
parent 64de972713
commit fcfcc3e127

View File

@@ -125,15 +125,25 @@ class _AccountSettingsDialogState extends State<AccountSettingsDialog> {
// Update auth state
context.read<AuthBloc>().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);