gpt4 book ai didi

flutter - 如何解决失败的断言 : line 110 pos 12: '_positions.isNotEmpty' : ScrollController not attached to any scroll views

转载 作者:行者123 更新时间:2023-12-04 13:15:31 28 4
gpt4 key购买 nike

还可以在 StackOverflow 上找到解决方案,但在我的情况下不起作用

'_positions.isNotEmpty': ScrollController not attached to any scroll views

PageView throws '_positions.isNotEmpty': ScrollController not attached to any scroll views

Widget _buildIntroSlider() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 46.0),
child: Stack(
alignment: AlignmentDirectional.bottomCenter,
children: <Widget>[
PageView.builder(
scrollDirection: Axis.horizontal,
controller: _pageController,
onPageChanged: _onPageChanged,
itemCount: slideList.length,
itemBuilder: (ctx, i) =>
SlideItem(slide: slideList[i], bold: false),
),

],
),
);
}

最佳答案

每当您使用 PageController 时,您需要记住,如果您尝试访问 PageController 数据,例如呈现具有该特定 Controller 的 PageView 之前的当前索引,您将收到此错误。
您可以检查它是否是 aleady 构建的
_pageController.hasClients
如果没有,则不能调用 Controller 的任何其他方法,否则会引发错误。

关于flutter - 如何解决失败的断言 : line 110 pos 12: '_positions.isNotEmpty' : ScrollController not attached to any scroll views,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60967898/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com