getMutedConversations static method
- {dynamic onSuccess(
- List<
MutedConversation> mutedConversations
- List<
- dynamic onError( )?}
Retrieves a list of conversations that have been muted by the logged-in user.
This method makes an asynchronous call to the CometChat server to fetch all muted conversations.
Upon successful retrieval, onSuccess
is invoked with a list of MutedConversation objects.
If an error occurs, onError
is called with a CometChatException.
Returns a Future<List<MutedConversation>> which completes with the list of muted conversations, or an empty list if an error occurs.
Implementation
static Future<List<MutedConversation>> getMutedConversations({Function(List<MutedConversation> mutedConversations)? onSuccess, Function(CometChatException e)? onError}) async {
List<MutedConversation> mutedConversations = [];
try {
final result = await channel.invokeMethod('getMutedConversations');
Map<dynamic, dynamic> map = result;
map.forEach((key, value) {
mutedConversations.add(MutedConversation.fromMap(value));
});
if(onSuccess != null) onSuccess(mutedConversations);
return mutedConversations;
} on PlatformException catch (platformException) {
if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
} catch (e) {
if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
}
return mutedConversations;
}