cfug / cfug/dio

ServerSendEvent support for Flutter Web

Open
#1,859 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

e: PR welcomed p: dio s: feature
Dominant language
Dart
Stars
12.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Request Statement

When request for ServerSendEvent stream on TargetPlatform: Web, it response with a UnsupportedError: RawSocket constructor

  Stream<T> requestForServerSendEventStream<T>(String url, Map<String, dynamic> request,
      {required void Function(CancelData cancelData) onCancel}) {
    final controller = StreamController<T>.broadcast();
    final cancelData = CancelData(cancelToken: CancelToken());
    try {
      onCancel(cancelData);
      _dio
          .post(url,
              cancelToken: cancelData.cancelToken,
              data: json.encode(request),
              options: Options(responseType: ResponseType.stream))
          .then((it) {
        it.data.stream.listen((it) {
          // ...
        }, onDone: () {
          controller.close();
        }, onError: (err, t) {
          // ...
        });
      }, onError: (err, t) {
        // ...
      });
    } on DioException catch (e) {
      // ...
    }
    return controller.stream;
  }
Solution Brainstorm

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Dio's Flutter Web request path and the RawSocket usage behind the shown ResponseType.stream call. Compare the web adapter with the existing streaming implementation; done means ServerSendEvent requests work on Flutter Web without the UnsupportedError. No specific files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.