Swiper使用过程中异常问题
轮播图数量变化导致问题异常信息:
Failed assertion: line 112 pos 12: '_positions.isNotEmpty': ScrollController
ScrollController not attached to any scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 110 pos 12: '_positions.isNotEmpty'
可能场景:多个Tab,每个Tab下一个Swiper,Swiper组件中,切换tab时出现System Error
解决方法:增加key属性
key是用来作为Widget、Element和SemanticsNode的标示,仅仅用来更新widget->key相同的小部件的状态。
Key子类包含LocalKey和GlobalKey。
Swiper(
itemCount: image_length,
loop: true,