0

我在使用上述方法时遇到问题,它按预期返回了一个列表,但 chatIds 是空的。这是我的代码:

Future<String> _getChats() async {

    final result = await context.read<TelegramService>().send(
        TdApi.GetChats(limit: 999),
    );

    TdApi.Chats chats = result;

    print(chats.totalCount);

    contacts.clear();

    print(chats.chatIds);

    for (var i = 0; i < chats.totalCount; i++) {
      final result = await context.read<TelegramService>().send(TdApi.GetChat(chatId: chats.chatIds[i]),);

      print(result);

      TdApi.Chat chat = result;

      final contact = TextButton(
        onPressed: () {
          locator<NavigationService>().navigateTo(route);
          Variables.setContactName(chat.title);
          Variables.setContactID(chat.id);
        },
        child: Text(chat.title),
      );

      contacts.add(contact);

    }
    String state = "Contacts Retrieved ";
    return state;
  }

这是我正在使用的库端口的链接https://pub.dev/packages/tdlib。其他方法在相同的原理下工作得很好,但是,这不是。

4

0 回答 0