fetchNext method
Future<List<GroupMember> >
fetchNext({
- required dynamic onSuccess(
- List<
GroupMember> groupMemberList
- List<
- required dynamic onError(
- CometChatException excep
fetch the list of groups members for a group , returns List of GroupMember.
Implementation
Future<List<GroupMember>> fetchNext(
{required Function(List<GroupMember> groupMemberList)? onSuccess,
required Function(CometChatException excep)? onError}) async {
try {
final result = await channel.invokeMethod('fetchNextGroupMembers', {
'guid': this.guid,
'limit': this.limit,
'keyword': this.searchKeyword,
'scopes': this.scopes,
'key': this.key
});
final List<GroupMember> res = [];
if (result != null) {
key = result["key"];
if (result["list"] != null) {
for (var _obj in result["list"]) {
try {
res.add(GroupMember.fromMap(_obj));
} catch (e) {
if (onError != null) {
onError(CometChatException(ErrorCode.errorUnhandledException,
e.toString(), e.toString()));
}
return [];
}
}
}
}
if (onSuccess != null) onSuccess(res);
return res;
} on PlatformException catch (platformException) {
if (onError != null) {
onError(CometChatException(platformException.code,
platformException.details, platformException.message));
}
} catch (e) {
debugPrint("Error: $e");
if (onError != null) {
onError(CometChatException(
ErrorCode.errorUnhandledException, e.toString(), e.toString()));
}
}
return [];
}