diff --git a/lib/src/impl/agora_video_view_impl.dart b/lib/src/impl/agora_video_view_impl.dart index c4543eeda..10ba5279e 100644 --- a/lib/src/impl/agora_video_view_impl.dart +++ b/lib/src/impl/agora_video_view_impl.dart @@ -315,7 +315,7 @@ class _AgoraRtcRenderTextureState extends State if (!_controllerInternal!.isInitialzed) { _listener ??= () { - _controllerInternal!.removeInitializedCompletedListener(_listener!); + _controllerInternal?.removeInitializedCompletedListener(_listener!); _listener = null; _initializeTexture(); @@ -327,6 +327,10 @@ class _AgoraRtcRenderTextureState extends State } Future _initializeTexture() async { + if (_controllerInternal == null) { + return; + } + final oldTextureId = _controllerInternal!.getTextureId(); await _controllerInternal!.initializeRender(); final textureId = _controllerInternal!.getTextureId();