add hacky check for resizing

This commit is contained in:
Nick Fisher
2024-05-10 23:05:05 +08:00
parent a7fb516ff3
commit 6f0df56751

View File

@@ -103,14 +103,26 @@ class _FilamentWidgetState extends State<FilamentWidget> {
} }
} }
bool _resizing = false;
Future _resizeTexture(Size newSize) async { Future _resizeTexture(Size newSize) async {
if (_resizing) {
return;
}
await Future.delayed(Duration.zero);
if (_resizing) {
return;
}
_resizing = true;
var dpr = MediaQuery.of(context).devicePixelRatio; var dpr = MediaQuery.of(context).devicePixelRatio;
_texture = await widget.plugin.resizeTexture( _texture = await widget.plugin.resizeTexture(_texture!,
_texture!, (dpr * newSize.width).ceil(), (dpr * newSize.height).ceil(), 0, 0); (dpr * newSize.width).ceil(), (dpr * newSize.height).ceil(), 0, 0);
print( print(
"Resized texture, new flutter ID is ${_texture!.flutterTextureId} (hardware ID ${_texture!.hardwareTextureId})"); "Resized texture, new flutter ID is ${_texture!.flutterTextureId} (hardware ID ${_texture!.hardwareTextureId})");
setState(() {}); setState(() {});
_resizing = false;
} }
@override @override