diff --git a/lib/src/rtc_data_channel_impl.dart b/lib/src/rtc_data_channel_impl.dart index a9ab3f7..08855f7 100644 --- a/lib/src/rtc_data_channel_impl.dart +++ b/lib/src/rtc_data_channel_impl.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:js_interop'; +import 'package:js/js_util.dart' as jsutil; import 'package:web/web.dart' as web; import 'package:webrtc_interface/webrtc_interface.dart'; @@ -71,8 +72,11 @@ class RTCDataChannelWeb extends RTCDataChannel { dynamic arrayBuffer; if (data is JSArrayBuffer) { arrayBuffer = data.toDart; + } else if (data is web.Blob) { + arrayBuffer = await jsutil + .promiseToFuture(jsutil.callMethod(data, 'arrayBuffer', [])); } else { - arrayBuffer = data.toString(); + arrayBuffer = data.toDart; } return RTCDataChannelMessage.fromBinary(arrayBuffer.asUint8List()); }