diff --git a/thermion_flutter/thermion_flutter/lib/src/widgets/src/thermion_widget.dart b/thermion_flutter/thermion_flutter/lib/src/widgets/src/thermion_widget.dart index 31cf49cc..6e909c7d 100644 --- a/thermion_flutter/thermion_flutter/lib/src/widgets/src/thermion_widget.dart +++ b/thermion_flutter/thermion_flutter/lib/src/widgets/src/thermion_widget.dart @@ -12,11 +12,9 @@ import 'package:thermion_flutter_web/thermion_flutter_web_options.dart'; import 'resize_observer.dart'; class ThermionWidget extends StatefulWidget { - final ThermionViewer viewer; final ThermionFlutterOptions? options; - /// /// The content to render before the texture widget is available. /// The default is a solid red Container, intentionally chosen to make it clear that there will be at least one frame where the Texture widget is not being rendered. @@ -63,13 +61,19 @@ class _ThermionWidgetState extends State { super.initState(); } - void _requestFrame() { - WidgetsBinding.instance.scheduleFrameCallback((d) { - widget.viewer.requestFrame(); - _requestFrame(); - }); - } +bool _rendering = false; + +void _requestFrame() { + WidgetsBinding.instance.scheduleFrameCallback((d) async { + if (!_rendering) { + _rendering = true; + await widget.viewer.requestFrame(); + _rendering = false; + } + _requestFrame(); + }); +} bool _resizing = false; Timer? _resizeTimer;