【发布时间】:2019-11-05 10:04:43
【问题描述】:
我正在 Persistent 底部工作表中创建一个带有点指示符的 PageView。 底部工作表显示页面视图和点指示符。但是当我水平滚动时,它在点视图中没有效果。
我的代码层次结构如下:
class zzz extends StatefulWidget with ccc {
@override
State createState() => new xxxState();
}
class xxxState extends State< zzz > with qqq {
..
...
Stack(
pageview(
onPageChanged: (index) {
setState(() {
this.bottomSheetCurrentIndex = index;
});
},
)
dotsView()
)
下面的点视图:
Widget dotsview(double pages) {
return Container(
width: MediaQuery.of(context).size.width,
height: 40,
child: ListView.builder(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.only(left: 180),
itemCount: pages.toInt(),
itemBuilder: (BuildContext context, int index) {
return Container(
height: 10,
width: 10,
child: dotcontainer(pages, index),
);
}
)
);
}
//indicator style
Container dotcontainer(double pages, int index) {
return Container(
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 2.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: this.bottomSheetCurrentIndex == index
? Colors.blue
: Colors.grey),
);
}
为什么?有什么解决办法吗?
【问题讨论】: