fix cancelling resize timer
This commit is contained in:
@@ -75,11 +75,12 @@ class FilamentWidget extends StatefulWidget {
|
|||||||
class _FilamentWidgetState extends State<FilamentWidget> {
|
class _FilamentWidgetState extends State<FilamentWidget> {
|
||||||
StreamSubscription? _textureIdListener;
|
StreamSubscription? _textureIdListener;
|
||||||
int? _textureId;
|
int? _textureId;
|
||||||
bool _resizing = false;
|
|
||||||
|
|
||||||
late final AppLifecycleListener _listener;
|
late final AppLifecycleListener _listener;
|
||||||
AppLifecycleState? _lastState;
|
AppLifecycleState? _lastState;
|
||||||
|
|
||||||
|
bool _resizing = false;
|
||||||
|
|
||||||
Timer? _resizeTimer;
|
Timer? _resizeTimer;
|
||||||
|
|
||||||
void _handleStateChange(AppLifecycleState state) async {
|
void _handleStateChange(AppLifecycleState state) async {
|
||||||
@@ -174,15 +175,15 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
child: ResizeObserver(
|
child: ResizeObserver(
|
||||||
onResized: (Size oldSize, Size newSize) async {
|
onResized: (Size oldSize, Size newSize) async {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
if (!_resizing) {
|
|
||||||
setState(() {
|
|
||||||
_resizing = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_resizeTimer?.cancel();
|
_resizeTimer?.cancel();
|
||||||
|
|
||||||
_resizeTimer = Timer(Duration(milliseconds: 500), () async {
|
_resizeTimer = Timer(Duration(milliseconds: 500), () async {
|
||||||
|
setState(() {
|
||||||
|
_resizing = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO - we could snapshot the widget to display while we resize?
|
||||||
|
|
||||||
print("Resizing to $newSize");
|
print("Resizing to $newSize");
|
||||||
await widget.controller
|
await widget.controller
|
||||||
.resize(newSize.width.toInt(), newSize.height.toInt());
|
.resize(newSize.width.toInt(), newSize.height.toInt());
|
||||||
|
|||||||
Reference in New Issue
Block a user