syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.57k stars 764 forks source link

Support WebAssembly for Flutter Web #1961

Open flawnn opened 3 months ago

flawnn commented 3 months ago

Bug description

As Syncfusion still depends on dart:html, all syncfusion flutter packages cannot be used when compiling Flutter Web applications via WebAssembly.

Solution: We should migrate to package:web.

Steps to reproduce

  1. Build Flutter project on version 3.22 with web target & WebAssembly flag enabled

Code sample

Code sample ```dart no code sample ```

Screenshots or Video

Screenshots / Video demonstration nothing to screen

Stack Traces

Stack Traces ```dart ../../../../../../.pub-cache/hosted/pub.dev/syncfusion_pdfviewer_web-24.2.8/lib/pdfviewer_web.dart:2:8: Error: Dart library 'dart:html' is not available on this platform. import 'dart:html' as html; ```

On which target platforms have you observed this bug?

Web, Web (Android browser), Web (iOS browser)

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-DE) • Flutter version 3.22.2 on channel stable at /Users/flawn/fvm/versions/3.22.2 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (4 weeks ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3 ```
flawnn commented 3 months ago

I tried to port it myself in my fork (https://github.com/flawnn/flutter-widgets) but I couldn't finish it up - I think I ported it probably wrong:

./../../../../../.pub-cache/git/flutter-widgets-a52886534a6dd475490b721b79cde74716589902/packages/syncfusion_pdfviewer_web/lib/src/pdfjs.dart:19:20:
Error: External JS interop member contains invalid types in its function signature: 'Settings Function({annotationMode: num?, canvasContext:
CanvasRenderingContext2D?, *data: Uint8List?*, offsetX: double?, offsetY: double?, scale: double?, viewport: PdfJsViewport?})'.
Use one of these valid types instead: JS types from 'dart:js_interop', ExternalDartReference, void, bool, num, double, int, String, extension types
that erase to one of these types, '@staticInterop' types, 'dart:html' types when compiling to JS, or a type parameter that is a subtype of a valid
non-primitive type.
  external factory Settings({
                   ^
../../../../../../.pub-cache/git/flutter-widgets-a52886534a6dd475490b721b79cde74716589902/packages/syncfusion_pdfviewer_web/lib/src/pdfjs.dart:49:26:
Error: External JS interop member contains an invalid type: 'List<num>'.
 - 'List' is from 'dart:core'.
Use one of these valid types instead: JS types from 'dart:js_interop', ExternalDartReference, void, bool, num, double, int, String, extension types
that erase to one of these types, '@staticInterop' types, 'dart:html' types when compiling to JS, or a type parameter that is a subtype of a valid
non-primitive type.
  external List<num> get view;
                         ^
immankumarsync commented 2 months ago

Hi @flawnn, we will analyze the feasibility of migrating to the web package and provide further details once the analysis is completed

sunderee commented 2 months ago

Hi, are there any updates to this issue?

immankumarsync commented 1 month ago

We have considered the request to provide Wasm support for Flutter PDF viewer. This feature enhancement will be included in any of our upcoming releases. Please follow the feedback link to track the status of this feature enhancement: Support for Web assembly in Flutter PDF viewer

flawnn commented 1 month ago

We have considered the request to provide Wasm support for Flutter PDF viewer. This feature enhancement will be included in any of our upcoming releases. Please follow the feedback link to track the status of this feature enhancement: Support for Web assembly in Flutter PDF viewer

This shouldn't be a feature as the migration to the package:web is a change which will happen anyway in the future - allocating now the work (and with that enabling a lot of people to build their projects on web with WebAssembly) would be very cool.