AS-Devs / signalr_flutter

A flutter plugin for .net SignalR client.
https://pub.dev/packages/signalr_flutter
MIT License
19 stars 27 forks source link

Streaming problem #59

Open AmirHosseinBaderan opened 7 months ago

AmirHosseinBaderan commented 7 months ago

i want to send an IAsyncEnumerable to server for streaming and i used multiple of types that all of them not working my question is : how do i do it?

the code i wrote :


Future<FileResponse<FtmFile?>> upload(UploadFile file) async {
    try {
      await start();
      final request = await _uploadRequest(RequestUpload.fromUploadFile(file));
      if (request.status.toLowerCase() == 'success') {
        final base64 = base64Encode(file.buffer);
        final subject = Stream.fromIterable(_makeChunck(base64));
        final response = await _connection?.invoke(_FileMethods.upload, args: [
          request.result!,
          subject,
        ]);
        return FileResponse<FtmFile?>.fromJson(
            response as Map<String, Object?>);
      } else {
        return FileResponse(
          result: null,
          status: request.status,
        );
      }
    } catch (e) {
      return FileResponse(
        result: null,
        status: 'fail',
      );
    } finally {
      await _connection?.stop();
    }
  }

the error i get : RangeError (RangeError (index): Invalid value: Valid value range is empty: 1)