fetchNext method
Future<List<Group> >
fetchNext({
- required dynamic onSuccess()?,
- required dynamic onError(
- CometChatException excep
Returns list of Group object fetched after putting the filters.
Implementation
Future<List<Group>> fetchNext(
{required Function(List<Group> groupList)? onSuccess,
required Function(CometChatException excep)? onError}) async {
try {
final result = await channel.invokeMethod('fetchNextGroups', {
'searchTerm': this.searchKeyword,
'limit': this.limit,
'joinedOnly': this.joinedOnly,
'tags': this.tags,
'withTags': this.withTags,
'key': this.key
});
final List<Group> res = [];
if (result != null) {
key = result["key"];
if (result["list"] != null) {
for (var _obj in result["list"]) {
try {
res.add(Group.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 [];
}