首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >发生异常。糟糕的状态:在flutter列表视图和视频播放器中已经完成了未来

发生异常。糟糕的状态:在flutter列表视图和视频播放器中已经完成了未来
EN

Stack Overflow用户
提问于 2018-08-25 04:45:20
回答 1查看 13K关注 0票数 3

我从我的CloudFirestore DB中获取了一个视频url,并在listView.buiilder()中显示网络视频。

当我设置

代码语言:javascript
运行
复制
autiInitialize = true

或者尝试以任何其他方式初始化视频时出现错误

代码语言:javascript
运行
复制
Exception has occurred.
Bad state: Future already completed

代码语言:javascript
运行
复制
I/flutter ( 6187): ══╡ EXCEPTION CAUGHT BY FOUNDATION LIBRARY ╞════════════════════════════════════════════════════════
I/flutter ( 6187): The following assertion was thrown while dispatching notifications for VideoPlayerController: 
I/flutter ( 6187): setState() or markNeedsBuild() called during build.
I/flutter ( 6187): This MaterialControls widget cannot be marked as needing to build because the framework is already
I/flutter ( 6187): in the process of building widgets. A widget can be marked as needing to be built during the build
I/flutter ( 6187): phase only if one of its ancestors is currently building. This exception is allowed because the
I/flutter ( 6187): framework builds parent widgets before children, which means a dirty descendant will always be
I/flutter ( 6187): built. Otherwise, the framework might not visit this widget during this build phase.
I/flutter ( 6187): The widget on which setState() or markNeedsBuild() was called was:
I/flutter ( 6187):   MaterialControls(state: _MaterialControlsState#47383)

我的部分代码

代码语言:javascript
运行
复制
VideoPlayerController  retcontroller(String varainatVideo){
    if(playercontroller == null){
      playercontroller = VideoPlayerController.network(varainatVideo);
    }
    return playercontroller;
  }


   Chewie(
  retcontroller(${snapshotDocuments[index].data['videos']}),
 autoInitialize: true,
cupertinoProgressColors: ChewieProgressColors(),
showControls:false,
 ),
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-25 23:50:37

看起来您正在尝试在UI构建期间更改状态,请确保您没有在ListView.builder(...)中使用setState(...)

this为例。

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52011477

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档