refactor: Centralize error and notification handling using a dedicated _errorService across various components.
This commit is contained in:
@@ -10,6 +10,7 @@ import '../../models/group.dart';
|
||||
import '../../models/group_member.dart';
|
||||
import '../../models/message.dart';
|
||||
import '../../repositories/group_repository.dart';
|
||||
import '../../services/error_service.dart';
|
||||
|
||||
/// Chat group content widget for group messaging functionality.
|
||||
///
|
||||
@@ -220,12 +221,7 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
||||
child: BlocConsumer<MessageBloc, MessageState>(
|
||||
listener: (context, state) {
|
||||
if (state is MessageError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.message),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
ErrorService().showError(message: state.message);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
@@ -871,20 +867,15 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
||||
// Le stream listener va automatiquement mettre à jour les membres
|
||||
// Pas besoin de fermer le dialog ou de faire un refresh manuel
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Pseudo modifié en "$newPseudo"'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
ErrorService().showSnackbar(
|
||||
message: 'Pseudo modifié en "$newPseudo"',
|
||||
isError: false,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Erreur lors de la modification du pseudo: $e'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
ErrorService().showError(
|
||||
message: 'Erreur lors de la modification du pseudo: $e',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user