getHiddenChannels static method
Implementation
static Future<bool> getHiddenChannels(
TPChannel? lastChannel,
Function(List<TPChannel>, bool) successCallback,
{
Function(int? errorCode, String? errorMessage)? errorCallback
}) async
{
if (!_isInitialized(errorCallback: errorCallback)) { return false; }
if (!_checkAuthInfo(errorCallback: errorCallback)) { return false; }
List<TPChannel>? list;
bool hasNext = false;
try {
Map<String, dynamic> queryParameters = {"type": "hidden"};
if (lastChannel != null) { queryParameters["lastChannelId"] = lastChannel.getChannelId(); }
Map<String, dynamic> response = await HttpUtil.get("/channels", queryParameters: queryParameters);
List<dynamic> channelArray = response["channels"];
list = List.from([]);
for (Map<String, dynamic> element in channelArray) {
list.add(TPChannel(element));
}
hasNext = response["hasNext"] as bool? ?? false;
} on TPException catch(e) {
Logger.log("${e.getCode()}, ${e.getMessage()}");
errorCallback?.call(e.getCode(), e.getMessage());
} catch(e){
Logger.log("$e");
errorCallback?.call(-1, e.toString());
}
if (list != null) {
successCallback(list, hasNext);
return true;
}
return false;
}