Flutter Stream Controller adding from a void method

Viewed 42

Is there a better way to add response to a stream i flutter from a void method without using Future.delayed trick

Future<void> upploadChattoCurrent(user_id) async {
    allchatRomms.forEach((key, value) {
      if (value.user.id == user_id) {
        Future.delayed(Duration(seconds: 0)).then(
            (value) => {streamController.sink.add(allchatRomms[key]!.chats)});
      }
    });
  }
0 Answers
Related