diff --git a/thermion_flutter/thermion_flutter/lib/src/widgets/src/thermion_texture_widget.dart b/thermion_flutter/thermion_flutter/lib/src/widgets/src/thermion_texture_widget.dart index f334b997..83f4cf21 100644 --- a/thermion_flutter/thermion_flutter/lib/src/widgets/src/thermion_texture_widget.dart +++ b/thermion_flutter/thermion_flutter/lib/src/widgets/src/thermion_texture_widget.dart @@ -56,10 +56,12 @@ class _ThermionTextureWidgetState extends State { @override void dispose() { + final texture = _texture; + _texture = null; super.dispose(); _views.remove(widget.viewer.view); - if (_texture != null) { - ThermionFlutterPlatform.instance.destroyTextureDescriptor(_texture!); + if (texture != null) { + ThermionFlutterPlatform.instance.destroyTextureDescriptor(texture!); } _fpsUpdateTimer?.cancel(); _states.remove(this); @@ -131,6 +133,7 @@ class _ThermionTextureWidgetState extends State { widget.viewer.onDispose(() async { var texture = _texture; + _texture = null; if (mounted) { setState(() {}); }