streamFileUploadRequestById method

  1. @override
Stream<MediaBuilder?> streamFileUploadRequestById(
  1. String id
)
override

Implementation

@override
Stream<MediaBuilder?> streamFileUploadRequestById(String id) {
  try {
    return _streamFileUploadRequestByIdEventChannel
        .receiveBroadcastStream(id)
        .map<MediaBuilder?>((event) {
      if (event == null || event == '{}') {
        return null;
      }

      final jsonData = event is String
          ? jsonDecode(event) as Map<String, dynamic>
          : Map<String, dynamic>.from(event as Map);
      return _buildMediaBuilderFromJsonMap(jsonData, requireFilePath: true);
    }).asBroadcastStream();
  } on PlatformException catch (e) {
    throw PlatformException(
      code: 'STREAM_ERROR',
      message: e.message,
      details: e.toString(),
    );
  }
}