correctly complete completer when resizing while unmounted and log any errors on resize
This commit is contained in:
@@ -171,20 +171,27 @@ class _SizedFilamentWidgetState extends State<_SizedFilamentWidget> {
|
|||||||
Duration(milliseconds: (kReleaseMode || Platform.isWindows) ? 10 : 100),
|
Duration(milliseconds: (kReleaseMode || Platform.isWindows) ? 10 : 100),
|
||||||
() async {
|
() async {
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
|
completer.complete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (_resizing) {
|
try {
|
||||||
await Future.delayed(const Duration(milliseconds: 20));
|
while (_resizing) {
|
||||||
}
|
await Future.delayed(const Duration(milliseconds: 20));
|
||||||
|
}
|
||||||
|
|
||||||
_resizing = true;
|
_resizing = true;
|
||||||
await widget.controller.setDimensions(_rect, _pixelRatio);
|
await widget.controller.setDimensions(_rect, _pixelRatio);
|
||||||
await widget.controller.resize();
|
await widget.controller.resize();
|
||||||
_resizeTimer = null;
|
_resizeTimer = null;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
_resizing = false;
|
_resizing = false;
|
||||||
completer.complete();
|
} catch (err) {
|
||||||
|
print("Error resizing FilamentWidget: $err");
|
||||||
|
} finally {
|
||||||
|
completer.complete();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user