美文网首页
swiper:Bad state: No element与_po

swiper:Bad state: No element与_po

作者: Duzzi | 来源:发表于2019-12-26 16:44 被阅读0次

CustomeScrollView嵌套使用flutter_swiper遇到了这么个问题:

当从服务器端获取的banner数量改变时,会出现Bad state: No element_positions.isNotEmpty的报错

解决方法:
给Swiper设置key

Swiper(
    key: ValueKey(ListUtils.size(mBanners)),
    itemBuilder: (BuildContext context, int index) {
    return buildBannerItem(index);
    },
    itemCount: ListUtils.size(mBanners),
    ...
)

thanks:
https://github.com/best-flutter/flutter_swiper/issues/64
https://www.jianshu.com/p/fc88c0774078
https://api.flutter.dev/flutter/foundation/Key-class.html

相关文章

网友评论

      本文标题:swiper:Bad state: No element与_po

      本文链接:https://www.haomeiwen.com/subject/xfcloctx.html