don't use resize callback on Windows and use ListenableBuilder for texture ID changes
don't use resize callback on Windows and use ListenableBuilder for texture ID changes
This commit is contained in:
@@ -42,7 +42,7 @@ class _RenderResizeObserver extends RenderProxyBox {
|
|||||||
void performLayout() async {
|
void performLayout() async {
|
||||||
super.performLayout();
|
super.performLayout();
|
||||||
if (size.width != _oldSize.width || size.height != _oldSize.height) {
|
if (size.width != _oldSize.width || size.height != _oldSize.height) {
|
||||||
onLayoutChangedCallback(size);
|
onLayoutChangedCallback(size);
|
||||||
_oldSize = Size(size.width, size.height);
|
_oldSize = Size(size.width, size.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,6 +87,9 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
|
|
||||||
return ResizeObserver(
|
return ResizeObserver(
|
||||||
onResized: (newSize) {
|
onResized: (newSize) {
|
||||||
|
if(!Platform.isWindows) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_width = newSize.width.ceil();
|
_width = newSize.width.ceil();
|
||||||
@@ -249,28 +252,31 @@ class _SizedFilamentWidgetState extends State<_SizedFilamentWidget> {
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.controller.textureDetails == null) {
|
return ListenableBuilder(listenable: widget.controller.textureDetails, builder: (BuildContext ctx, Widget? wdgt) {
|
||||||
return Stack(children: [
|
|
||||||
Positioned.fill(child: widget.initial ?? Container(color: Colors.red))
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// see [FilamentControllerFFI.resize] for an explanation of how we deal with resizing
|
|
||||||
var texture = Texture(
|
|
||||||
key: ObjectKey("texture_${widget.controller.textureDetails!.textureId}"),
|
|
||||||
textureId: widget.controller.textureDetails!.textureId,
|
|
||||||
filterQuality: FilterQuality.none,
|
|
||||||
freeze: false,
|
|
||||||
);
|
|
||||||
|
|
||||||
return Stack(children: [
|
if (widget.controller.textureDetails.value == null) {
|
||||||
Positioned.fill(
|
return Stack(children: [
|
||||||
child: Platform.isLinux || Platform.isWindows
|
Positioned.fill(child: widget.initial ?? Container(color: Colors.red))
|
||||||
? Transform(
|
]);
|
||||||
alignment: Alignment.center,
|
}
|
||||||
transform: Matrix4.rotationX(
|
// see [FilamentControllerFFI.resize] for an explanation of how we deal with resizing
|
||||||
pi), // TODO - this rotation is due to OpenGL texture coordinate working in a different space from Flutter, can we move this to the C++ side somewhere?
|
var texture = Texture(
|
||||||
child: texture)
|
key: ObjectKey("texture_${widget.controller.textureDetails.value!.textureId}"),
|
||||||
: texture)
|
textureId: widget.controller.textureDetails.value!.textureId,
|
||||||
]);
|
filterQuality: FilterQuality.none,
|
||||||
|
freeze: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
return Stack(children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: Platform.isLinux || Platform.isWindows
|
||||||
|
? Transform(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
transform: Matrix4.rotationX(
|
||||||
|
pi), // TODO - this rotation is due to OpenGL texture coordinate working in a different space from Flutter, can we move this to the C++ side somewhere?
|
||||||
|
child: texture)
|
||||||
|
: texture)
|
||||||
|
]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user