createclient method

Future<Map> createclient({
  1. required int clientId,
  2. int clientUserId = 0,
  3. TdlibOptionParameter? clientOption,
  4. bool isBot = false,
  5. bool isVoid = false,
})

add this for multithread on flutter apps

Implementation

Future<Map> createclient({
  required int clientId,
  int clientUserId = 0,
  TdlibOptionParameter? clientOption,
  bool isBot = false,
  bool isVoid = false,
}) async {
  //
  Map client_new_option = client_option.rawData.clone();
  if (clientOption != null) {
    // client_new_option.addAll(clientOption);
  }
  TdlibClient tdlibClient = TdlibClient(
    client_id: clientId,
    client_user_id: clientUserId,
    client_option: client_new_option,
  );
  if ((is_init_isolate == false)) {
    clients[clientId] = tdlibClient;
    is_init_isolate = true;
  } else {
    // sendPort.send(tdlibClient);
    clients[clientId] = tdlibClient;
  }

  return await invoke(
    "setTdlibParameters",
    parameters: client_new_option,
    isUseCache: false,
    durationCacheExpire: null,
    clientId: clientId,
    isVoid: isVoid,
    isInvokeThrowOnError: false,
  );
}