'WebRtc connection in dart:html, incomplete API?

What would be the equivalent in dart of the following javascript snippet?

myPeerConnection.createOffer().then(function(offer) {
  return myPeerConnection.setLocalDescription(offer);
})

The straight translation:

final offer = await myPeerConnection.createOffer();
myPeerConnection.setLocalDescription(offer);

does not compile because createOffer() eventually returns a RtcSessionDescription and setLocalDescription accepts only a Map.

And RtcSessionDescription does not have a nice way to convert to a Map in the API.

Am I missing anything? Thanks!



Solution 1:[1]

After trying a few things, this works in my use case (at least in Chrome):

final offer = await myPeerConnection.createOffer();
myPeerConnection.setLocalDescription({"sdp": offer.sdp, "type": offer.type ?? 'offer'});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user2916923