' 代码中没有这样的映射,flutter,websocket,webrtc,flutter-dependencies"/>

首页 > 解决方案 > flutter_ion 1.0.0:错误:需要一个“SessionDescription”类型的值,但得到一个“IdentityMap”类型的值' 代码中没有这样的映射

问题描述

这个 Flutter 应用程序的目的是在 2 个用户之间打开一个流,我使用ion-sfu作为服务器,在前端使用 flutter-ion:^0.5.4,当我运行 Web 时它运行良好,但是当我将颤振离子从 ^0.5.4 更新到 ^1.0.0它给了我下面的错误。PS:我需要将 Flutter-ion 更新为 ^1.0.0,因为当我使用 flutter-ion:^0.5.4 时,我的应用程序无法在 Windows 桌面上正确运行,有什么帮助吗?

void pubSub() async {
   // setState(() {
   //   plist.clear();
   // });
   log("serverurl " + ServerURL);
   //if (_client == null) {
   // create new client
   _client =
       await ion.Client.create(sid: "test room", uid: _uuid, signal: _signal);

   // peer ontrack
   _client?.ontrack = (track, ion.RemoteStream remoteStream) async {
     if (track.kind == 'video') {
       print('ontrack: remote stream: ${remoteStream.stream}');
       var renderer = RTCVideoRenderer();
       await renderer.initialize();
       renderer.srcObject = remoteStream.stream;
       setState(() {
         plist.add(Participant('RemoteStream', renderer, remoteStream.stream));
       });
     }
   };

   _localStream = await ion.LocalStream.getUserMedia(constraints: stts);
   //_localStream2 = await ion.LocalStream.getUserMedia(constraints: stts);

   // publish the stream
   await _client?.publish(_localStream!);

   var renderer = RTCVideoRenderer();
   await renderer.initialize();
   renderer.srcObject = _localStream?.stream;
   setState(() {
     qlist.add(Participant("LocalStream", renderer, _localStream?.stream));
   });
 }
Error: Expected a value of type 'SessionDescription', but got one of type 'IdentityMap<String, String?>'
    at Object.throw_ [as throw] (http://localhost:54173/dart_sdk.js:5083:11)
    at Object.castError (http://localhost:54173/dart_sdk.js:5042:15)
    at Object.cast [as as] (http://localhost:54173/dart_sdk.js:5367:17)
    at Function.as_C [as as] (http://localhost:54173/dart_sdk.js:4988:19)
    at http://localhost:54173/packages/flutter_ion/src/signal/signal_grpc_impl.dart.lib.js:178:56
    at http://localhost:54173/packages/flutter_ion/src/signal/signal_grpc_impl.dart.lib.js:182:11
    at signal_grpc_impl.GRPCWebSignal.new.join (http://localhost:54173/packages/flutter_ion/src/signal/signal_grpc_impl.dart.lib.js:184:9)
    at client$.Client.new.<anonymous> (http://localhost:54173/packages/flutter_ion/src/stream.dart.lib.js:1035:49)
    at Generator.next (<anonymous>)
    at http://localhost:54173/dart_sdk.js:40108:33
    at _RootZone.runUnary (http://localhost:54173/dart_sdk.js:39979:59)
    at _FutureListener.thenAwait.handleValue (http://localhost:54173/dart_sdk.js:34926:29)
    at handleValueCallback (http://localhost:54173/dart_sdk.js:35493:49)
    at Function._propagateToListeners (http://localhost:54173/dart_sdk.js:35531:17)
    at _Future.new.[_completeWithValue] (http://localhost:54173/dart_sdk.js:35379:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:54173/dart_sdk.js:35400:35)
    at Object._microtaskLoop (http://localhost:54173/dart_sdk.js:40246:13)
    at _startMicrotaskLoop (http://localhost:54173/dart_sdk.js:40252:13)
    at http://localhost:54173/dart_sdk.js:35751:9

标签: flutterwebsocketwebrtcflutter-dependencies

解决方案


推荐阅读