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