颤振流控制器无法获取数据



im面临以下错误:

E/flutter (24904): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_AsBroadcastStream<dynamic>' is not a subtype of type 'bool'
E/flutter (24904): #0      new VideocallBloc.<anonymous closure> (package:video_call/bloc/videocall/videocall_bloc.dart:40:61)
E/flutter (24904): #1      _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)

我有两个流控制器在运行:

final remoteStreamController = StreamController<dynamic>.broadcast();
Stream<dynamic> get remoteId =>
remoteStreamController.stream.asBroadcastStream();
final localStreamController  = StreamController<dynamic>.broadcast();
Stream<dynamic> get localJoined =>
localStreamController.stream.asBroadcastStream();

现在当我在我的CCD_ 1中传递信息时;localjoind";值,但我不知道如何访问它。。我怎样才能得到里面的值?

remoteStreamController.sink.add({
"engine":engine,
"localJoined": localJoined, <- This is causing my error
"remoteId": uid
});

编辑:

userJoined: (int uid, int elapsed) {
//final res = localJoined.last;
//  print('++ ppppppppppp ${res}');
print(
'++@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ remote user $uid joined channel');
localJoined.listen((value) {
print(
'++@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Value from localJoined: $value');
});
remoteStreamController.sink.add({"engine": engine, "localJoined": true, "remoteId": uid});

在@Shyam Patel和@pskink的帮助下,我想明白了。我现在正在缓存两个流的最后一个值,这样我就可以使用这些值了。

_repo.localJoined.listen((res) {
print('++ stream in bloc for local: $res');
_repo.lastLocal = res["localJoined"];
_repo.lastRemote = res["remoteId"];
add(UpdateVideoCall(engine: res["engine"], joined: _repo.lastLocal ?? false, remote: _repo.lastRemote ?? -1));
});
_repo.remoteId.listen((res) {
print('++ stream in bloc for remote: $res');
_repo.lastLocal = res["localJoined"];
_repo.lastRemote = res["remoteId"];
add(UpdateVideoCall(engine: res["engine"], joined: _repo.lastLocal ?? false, remote: _repo.lastRemote ?? -1));
});

最新更新