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
|
// Update auth state
|
||||||
context.read<AuthBloc>().add(UpdateUserProfile(updatedUser));
|
context.read<AuthBloc>().add(UpdateUserProfile(updatedUser));
|
||||||
|
|
||||||
|
// Show success message after the build cycle
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Profile updated successfully')),
|
const SnackBar(content: Text('Profile updated successfully')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(
|
// Show error message after the build cycle
|
||||||
context,
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
).showSnackBar(SnackBar(content: Text('Failed to update profile: $e')));
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Failed to update profile: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setState(() => _isLoading = false);
|
setState(() => _isLoading = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user