flutter_client_sse icon indicating copy to clipboard operation
flutter_client_sse copied to clipboard

Browser support not working

Open skaba opened this issue 3 years ago • 7 comments

Should the browser version wrap dart sse client (https://pub.dev/documentation/sse/latest/client_sse_client/SseClient-class.html) instead of using http client?

skaba avatar Feb 07 '22 07:02 skaba

The package was tested and intended for mobile use. Feel free to create a PR if you get it working on web.

pratikbaid3 avatar Feb 11 '22 08:02 pratikbaid3

That library uses EventSource from dart:html, which afaik is the only working way to use sse on flutter web. However, importing dart:html will raise Error: Not found when targeting at mobile platforms. ~~And dart/flutter doesn't support conditional import, so it seems that we can't have both mobile and browser compatibility at library level.~~ (See below)

foxB612 avatar Jul 13 '22 00:07 foxB612

dart/flutter doesn't support conditional import

@foxB612 I have seen conditional imports in some libraries that I use.

export 'send_port_io.dart' if (dart.library.html) 'send_port_web.dart';

These are from worker_manager package.

import 'package:worker_manager_v2/src/worker/worker_web.dart'
    if (dart.library.io) 'package:worker_manager_v2/src/worker/worker_io.dart';

srix55 avatar Jul 26 '22 15:07 srix55

@srix55 Thank you for pointing out that. I did get it wrong. According to the document conditional export/import is supported.

foxB612 avatar Jul 26 '22 23:07 foxB612

Is it still not working on the web? I do not receive any event until it is disconnected that they all arrive

AdrianRechina avatar Aug 22 '23 14:08 AdrianRechina

The package was tested and intended for mobile use. Feel free to create a PR if you get it working on web.

Then remove the Web tag on pub.dev this prevents misunderstandings.

cybertheory avatar Jul 03 '24 23:07 cybertheory

For everyone else

I found this issue regarding http on browser for streams

https://github.com/dart-lang/http/issues/593

Looks like streaming with http buffers the data first which is an issue I am hitting

cybertheory avatar Jul 03 '24 23:07 cybertheory