From 37f85587948bb0519660580f9197b49d1bd3dfd4 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Thu, 3 Jul 2025 13:04:24 +0800 Subject: [PATCH] add stub method for resizeWebCanvas to make pub.dev happy --- thermion_dart/lib/src/bindings/src/ffi.dart | 7 +++++-- thermion_dart/lib/src/bindings/src/js_interop.dart | 8 ++++++-- .../thermion_flutter_web/lib/thermion_flutter_web.dart | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/thermion_dart/lib/src/bindings/src/ffi.dart b/thermion_dart/lib/src/bindings/src/ffi.dart index 644530a6..614bc9c3 100644 --- a/thermion_dart/lib/src/bindings/src/ffi.dart +++ b/thermion_dart/lib/src/bindings/src/ffi.dart @@ -221,8 +221,11 @@ extension DartBigIntExtension on int { } extension Float32ListExtension on Float32List { - Uint8List asUint8List() { return this.buffer.asUint8List(this.offsetInBytes); } -} \ No newline at end of file +} + +void resizeWebCanvas(int width, int height) { + throw UnsupportedError("Not supported on non-web platforms"); +} diff --git a/thermion_dart/lib/src/bindings/src/js_interop.dart b/thermion_dart/lib/src/bindings/src/js_interop.dart index 9c4849d2..7c765cf0 100644 --- a/thermion_dart/lib/src/bindings/src/js_interop.dart +++ b/thermion_dart/lib/src/bindings/src/js_interop.dart @@ -157,7 +157,6 @@ extension Uint8ListExtension on Uint8List { extension Float32ListExtension on Float32List { Pointer get address { - final ptr = getPointer(this, this.toJS); final bar = Float32ArrayWrapper(NativeLibrary.instance.HEAPU8.buffer, ptr, length) @@ -167,7 +166,8 @@ extension Float32ListExtension on Float32List { } Uint8List asUint8List() { - var ptr = Pointer(_NativeLibrary.instance._emscripten_get_byte_offset(this.toJS)); + var ptr = Pointer( + _NativeLibrary.instance._emscripten_get_byte_offset(this.toJS)); return ptr.asTypedList(length * 4); } } @@ -468,3 +468,7 @@ void stackRestore(Pointer ptr) => void getStackFree() { print(_NativeLibrary.instance._emscripten_stack_get_free()); } + +void resizeWebCanvas(int width, int height) { + Thermion_resizeCanvas(width, height); +} diff --git a/thermion_flutter/thermion_flutter_web/lib/thermion_flutter_web.dart b/thermion_flutter/thermion_flutter_web/lib/thermion_flutter_web.dart index af334fcb..2772f27e 100644 --- a/thermion_flutter/thermion_flutter_web/lib/thermion_flutter_web.dart +++ b/thermion_flutter/thermion_flutter_web/lib/thermion_flutter_web.dart @@ -117,7 +117,7 @@ class ThermionFlutterWebPlugin extends ThermionFlutterPlatform { /// void resizeCanvas(double width, double height) async { _logger.info("Resizing canvas to ${width}x${height}"); - Thermion_resizeCanvas((window.devicePixelRatio * width).ceil(), + resizeWebCanvas((window.devicePixelRatio * width).ceil(), (window.devicePixelRatio * height).ceil()); } }