【问题标题】:PageView indicator dots not working in Persistent Bottomsheet FlutterPageView 指示点在 Persistent Bottomsheet Flutter 中不起作用
【发布时间】: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),
        );
  }

为什么?有什么解决办法吗?

【问题讨论】:

    标签: flutter pageviews


    【解决方案1】:

    像往常一样,我的大部分问题都没有从这个平台上得到答案。 无论如何,上述问题的答案是使用Scopped Model or Inherited widgets.

    谢谢

    【讨论】:

      猜你喜欢
      • 2017-07-18
      • 2020-04-11
      • 1970-01-01
      • 1970-01-01
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      • 2019-04-11
      • 2020-05-11
      相关资源
      最近更新 更多