re-add resize timer to FilamentWidget return initial widget when resizing
This commit is contained in:
@@ -28,7 +28,6 @@ class FilamentWidget extends StatefulWidget {
|
|||||||
class _FilamentWidgetState extends State<FilamentWidget> {
|
class _FilamentWidgetState extends State<FilamentWidget> {
|
||||||
FlutterFilamentTexture? _texture;
|
FlutterFilamentTexture? _texture;
|
||||||
|
|
||||||
|
|
||||||
Rect get _rect {
|
Rect get _rect {
|
||||||
final renderBox = (context.findRenderObject()) as RenderBox;
|
final renderBox = (context.findRenderObject()) as RenderBox;
|
||||||
final size = renderBox.size;
|
final size = renderBox.size;
|
||||||
@@ -61,18 +60,18 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool _resizing = false;
|
bool _resizing = false;
|
||||||
|
Timer? _resizeTimer;
|
||||||
|
|
||||||
Future _resizeTexture(Size newSize) async {
|
Future _resizeTexture(Size newSize) async {
|
||||||
|
_resizeTimer?.cancel();
|
||||||
|
_resizeTimer = Timer(Duration(milliseconds: 100), () async {
|
||||||
if (_resizing) {
|
if (_resizing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await Future.delayed(Duration.zero);
|
_resizeTimer!.cancel();
|
||||||
if (_resizing) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_resizing = true;
|
_resizing = true;
|
||||||
|
setState(() {});
|
||||||
|
|
||||||
var dpr = MediaQuery.of(context).devicePixelRatio;
|
var dpr = MediaQuery.of(context).devicePixelRatio;
|
||||||
|
|
||||||
@@ -82,11 +81,12 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
"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;
|
_resizing = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_texture == null) {
|
if (_texture == null || _resizing) {
|
||||||
return widget.initial ??
|
return widget.initial ??
|
||||||
Container(color: kIsWeb ? Colors.transparent : Colors.red);
|
Container(color: kIsWeb ? Colors.transparent : Colors.red);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user