createTopicInCommunity method

Future<V2TimValueCallback<String>> createTopicInCommunity({
  1. required String groupID,
  2. required V2TimTopicInfo topicInfo,
})

Implementation

Future<V2TimValueCallback<String>> createTopicInCommunity({
  required String groupID,
  required V2TimTopicInfo topicInfo,
}) async {
  try {
    final res = await wrappedPromiseToFuture(
        timeweb!.createTopicInCommunity(mapToJSObj({
      "groupID": groupID,
      "topicName": topicInfo.topicName,
      "avatar": topicInfo.topicFaceUrl,
      "notification": topicInfo.notification,
      "introduction": topicInfo.introduction,
      "customData": topicInfo.customString,
    })));
    var code = res.code;
    var result = jsToMap(res.data)["topicID"] as String;
    if (code == 0) {
      return CommonUtils.returnSuccess<String>(result);
    } else {
      return CommonUtils.returnErrorForValueCb<String>(
          "createTopicInCommunity Failed");
    }
  } catch (error) {
    return CommonUtils.returnErrorForValueCb<String>(error.toString());
  }
}