fix resizing

This commit is contained in:
Nick Fisher
2023-08-08 11:16:34 +08:00
parent 9fd02b12a4
commit 4ec9dbe756
4 changed files with 33 additions and 40 deletions

View File

@@ -97,21 +97,9 @@ class FilamentController {
Future resize(int width, int height,
{double contentScaleFactor = 1.0}) async {
// await setRendering(false);
// _textureIdController.add(null);
// await _channel.invokeMethod("destroy_swap_chain(_viewer);
// size = ui.Size(width * _pixelRatio, height * _pixelRatio);
// _textureId = await _channel.invokeMethod("resize",
// [width * _pixelRatio, height * _pixelRatio, contentScaleFactor]);
// _textureIdController.add(_textureId);
// await _channel.invokeMethod("create_swap_chain( nullptr, width, height);
// await _channel.invokeMethod("create_render_target(
// await _channel.invokeMethod("getGlTextureId"), width, height);
// await _channel.invokeMethod("update_viewport_and_camera_projection(
// width, height, contentScaleFactor);
// await setRendering(true);
_textureId = await _channel.invokeMethod("resize",
[width * _pixelRatio, height * _pixelRatio, contentScaleFactor]);
_textureIdController.add(_textureId);
}
void clearBackgroundImage() async {

View File

@@ -103,14 +103,19 @@ class _FilamentWidgetState extends State<FilamentWidget> {
width: constraints.maxWidth,
child: ResizeObserver(
onResized: (Size oldSize, Size newSize) async {
// setState(() {
// _resizing = true;
// });
WidgetsBinding.instance.addPostFrameCallback((_) async {
setState(() {
_resizing = true;
});
await widget.controller.resize(
newSize.width.toInt(), newSize.height.toInt());
setState(() {
_resizing = false;
await widget.controller.resize(
newSize.width.toInt(), newSize.height.toInt());
WidgetsBinding.instance
.addPostFrameCallback((_) async {
setState(() {
_resizing = false;
});
});
});
},
child: Platform.isLinux