diff --git a/flutter_package/lib/src/interface_web.dart b/flutter_package/lib/src/interface_web.dart index e0771fff..98ba2108 100644 --- a/flutter_package/lib/src/interface_web.dart +++ b/flutter_package/lib/src/interface_web.dart @@ -15,9 +15,9 @@ void setCompiledLibPathReal(String path) { Future prepareInterfaceReal( AssignRustSignal assignRustSignal, ) async { - // Check and create the namespace JavaScript object. + // Check if the web app was already loaded. + // This step is important because Dart has hot restart. checkIfAlreadyLoaded(); - createRinfBindingsObject(); // Listen to Rust via JavaScript. rinfBindingsObject['send_rust_signal_extern'] = ( diff --git a/flutter_package/lib/src/load_web.dart b/flutter_package/lib/src/load_web.dart index 4bd48f0a..55b199b8 100644 --- a/flutter_package/lib/src/load_web.dart +++ b/flutter_package/lib/src/load_web.dart @@ -11,7 +11,7 @@ void setJsLibPath(String path) { } bool wasAlreadyLoaded = false; -js.JsObject rinfBindingsObject = createRinfBindingsObject(); +js.JsObject rinfBindingsObject = getRinfBindingsObject(); js.JsObject wasmBindingsObject = js.context['wasmBindings']; /// When Dart performs hot restart, @@ -24,7 +24,7 @@ void checkIfAlreadyLoaded() { /// Create the namespace JavaScript object. /// This namespace object is used by Rust /// to call functions defined in Dart. -js.JsObject createRinfBindingsObject() { +js.JsObject getRinfBindingsObject() { // Create a new `rinfBindings` JavaScript object if not present. // Otherwise, return the existing one. final js.JsObject jsObject;