Flutter 周期性的团状流颤振

Flutter 周期性的团状流颤振,flutter,Flutter,我正在开发一个简单的聊天应用程序,我必须检查特定时间间隔的终端API 但在我的集团逻辑中,我使用了可观察的 那么,我如何更改代码以使该流具有周期性呢 final bloc = ConversationBloc(); class ConversationBloc { final repository = Repository(); final conversationFetcher = PublishSubject<ConversationModel>(); final

我正在开发一个简单的聊天应用程序,我必须检查特定时间间隔的终端API

但在我的集团逻辑中,我使用了可观察的

那么,我如何更改代码以使该流具有周期性呢

final bloc = ConversationBloc();

class ConversationBloc {
  final repository = Repository();
  final conversationFetcher = PublishSubject<ConversationModel>();
  final conversationFetcherStatus = PublishSubject<MessageModel>();

  Observable<ConversationModel> get userConversation =>
      conversationFetcher.stream;

  dispose() async {
    await conversationFetcher.drain();
    conversationFetcher.close();
    conversationFetcherStatus.close();
  }

  fetchUserConversation(toUsernameController) async {
    ConversationModel conversationModel =
        await repository.fetchUserConversation(toUsernameController);
    conversationFetcher.sink.add(conversationModel);
  }

  saveConversation(Data conversation) async {
    try {
      MessageModel conversationModel =
          await repository.saveConversation(conversation);
      conversationFetcherStatus.sink.add(conversationModel);
    } catch (e) {
      conversationFetcherStatus.sink.addError(e);
    }
  }

   fetchUserConversationList(int toUsernameController) async {
    ConversationModel conversationModel =
        await repository.fetchUserConversationList(toUsernameController);
    conversationFetcher.sink.add(conversationModel);
  }
}
final bloc=ConversationBloc();
阶级对话集团{
最终存储库=存储库();
final conversationFetcher=PublishSubject();
final conversationFetcherStatus=PublishSubject();
可观察的get-userConversation=>
conversationFetcher.stream;
dispose()异步{
等待conversationFetcher.drain();
conversationFetcher.close();
conversationFetcherStatus.close();
}
fetchUserConversation(toUsernameController)异步{
会话模型会话模型=
等待repository.fetchUserConversation(toUsernameController);
conversationFetcher.sink.add(conversationModel);
}
saveConversation(数据会话)异步{
试一试{
MessageModel会话模型=
wait repository.saveConversation(会话);
conversationFetcherStatus.sink.add(conversationModel);
}捕获(e){
conversationFetcherStatus.sink.addError(e);
}
}
fetchUserConversationList(int-toUsernameController)异步{
会话模型会话模型=
wait repository.fetchUserConversationList(toUsernameController);
conversationFetcher.sink.add(conversationModel);
}
}

我在您的应用程序中没有看到任何构造函数code@pskink这是一个10亿美元的问题,如何实施,因为我不知道如何实施。