使用flutter_swiper_view布局报错EXCEPTION CAUGHT BY RENDERING LIBRARY.....The relevant error-causing widget
使用了flutter_swiper_view来设置轮播图布局,直接使用Swiper()组件会报错:EXCEPTION CAUGHT BY RENDERING LIBRARY
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performResize():
Horizontal viewport was given unbounded height.
Viewports expand in the cross axis to fill their container and constrain their children to match
their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of
vertical space in which to expand.
The relevant error-causing widget was:
PageView
PageView:file:///C:/Users/user/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/flutter_swiper_view-1.1.8/li b/src/transformer_page_view.dart:423:29
从上面这个报错信息很容易看出是使用的 flutter_swiper_view的原因
解决方法
查看代码后发现,原来是我忘记了要用一个容器去包裹Swiper组件,只需要使用一个Container()或者SizeBox()组件包裹Swiper组件就可以解决问题了。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)