Delay showing profile update messages until after the build cycle to ensure proper UI updates
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user