Skip to content

Commit fb89bea

Browse files
committed
added u2
1 parent c9d4975 commit fb89bea

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

packages/fula_client/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Minimum Flutter version raised to 3.38.0 (Dart 3.10.x)
1313
- Minimum Dart SDK raised to 3.8.0 (required for freezed ^3.2.0)
1414
- CI/CD workflows updated to use Flutter 3.38.0 stable
15+
- Web plugin updated to use `package:web` and `dart:js_interop` (replacing deprecated `dart:html` and `dart:js`)
1516

1617
## [0.2.7] - 2026-01-11
1718

packages/fula_client/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
sdk: flutter
1818
flutter_rust_bridge: ^2.11.0
1919
freezed_annotation: ^3.1.0
20+
web: ^1.0.0
2021

2122
dev_dependencies:
2223
flutter_test:

packages/fula_client/web/fula_client_web.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
// The WASM module is loaded asynchronously when the plugin is first used.
55

66
import 'dart:async';
7-
import 'dart:html' as html;
8-
import 'dart:js' as js;
7+
import 'dart:js_interop';
98

109
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
10+
import 'package:web/web.dart' as web;
1111

1212
/// Web implementation of the Fula Client plugin.
1313
///
@@ -56,28 +56,31 @@ class FulaClientWeb {
5656
// They are generated by wasm-pack during the build process
5757
// Note: The JS file is named after the Rust crate (fula_flutter)
5858

59-
final script = html.ScriptElement()
59+
final script = web.HTMLScriptElement()
6060
..src = 'fula_flutter.js'
6161
..type = 'module';
6262

6363
final completer = Completer<void>();
6464

65-
script.onLoad.listen((_) async {
65+
script.onload = ((web.Event event) {
6666
// Call the init function exported by wasm-bindgen
67-
try {
68-
await js.context.callMethod('__wbg_init');
67+
_initWasm().toDart.then((_) {
6968
completer.complete();
70-
} catch (e) {
69+
}).catchError((e) {
7170
completer.completeError('Failed to initialize WASM: $e');
72-
}
73-
});
71+
});
72+
}).toJS;
7473

75-
script.onError.listen((event) {
74+
script.onerror = ((web.Event event) {
7675
completer.completeError('Failed to load WASM script');
77-
});
76+
}).toJS;
7877

79-
html.document.head!.append(script);
78+
web.document.head!.append(script);
8079

8180
return completer.future;
8281
}
8382
}
83+
84+
/// JS interop for the WASM init function
85+
@JS('__wbg_init')
86+
external JSPromise<JSAny?> _initWasm();

0 commit comments

Comments
 (0)