简体   繁体   English

颤动点指示器到页面浏览量

[英]flutter dot indicator to pageview

I want to add a dot indicator to pageview.我想在页面浏览中添加一个点指示器。 When a person scrolls the image to the right to left image changes on my code.当一个人将图像从右向左滚动时,我的代码中的图像会发生变化。 NO problem with there but I couldn't manage to add a dot indicator to my code.那里没问题,但我无法在我的代码中添加点指示器。 How can I put a dot indicator when I scroll across images also the dots switch to the order of images.........................................................................................................当我滚动图像时如何放置点指示器并且点切换到图像的顺序...................................... ………………………………………………………………………………………………………………………………………………………… ......................................

                            PageView.builder(
                    itemCount: totalCards.toInt(),
                    itemBuilder: (context, i) {
                      return Container(
                          margin: EdgeInsets.only(top: 10),
                          child: Container(
                            child: Column(
                              mainAxisAlignment:
                                  MainAxisAlignment.spaceBetween,
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: <Widget>[
                                Expanded(
                                  child: PageView(
                                    children: <Widget>[
                                      Container(
                                        decoration: BoxDecoration(
                                            borderRadius:
                                                BorderRadius.circular(4.0),
                                            image: DecorationImage(
                                                image: AssetImage(
                                                    photos[startphoto]),
                                                fit: BoxFit.cover)),
                                      ),
                                      Container(
                                        decoration: BoxDecoration(
                                            borderRadius:
                                                BorderRadius.circular(4.0),
                                            image: DecorationImage(
                                                image: AssetImage(
                                                    photos[startphoto1]),
                                                fit: BoxFit.cover)),
                                      ),
                                      Container(
                                        decoration: BoxDecoration(
                                            borderRadius:
                                                BorderRadius.circular(4.0),
                                            image: DecorationImage(
                                                image: AssetImage(
                                                    photos[startphoto2]),
                                                fit: BoxFit.fitHeight)),
                                      ),
                                      Container(
                                        decoration: BoxDecoration(
                                            borderRadius:
                                                BorderRadius.circular(4.0),
                                            image: DecorationImage(
                                                image: AssetImage(
                                                    photos[startphoto3]),
                                                fit: BoxFit.cover)),
                                      ),

                                    ],
                                  ),
                                ),
                              ],
                            ),
                          )
                      );
                    },
                  ),
                ),

You can do that with this package: https://pub.dev/packages/page_view_indicators你可以用这个包做到这一点: https : //pub.dev/packages/page_view_indicators

In the example you can see how to implement it.在示例中,您可以看到如何实现它。

EDIT: Implement your dot indicator like this:编辑:像这样实现你的点指示器:

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  final ValueNotifier<int> _pageNotifier = new ValueNotifier<int>(0);
  final PageController _pageController = new PageController();

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        PageView.builder(
          itemCount: totalCards.toInt(),
          controller: _pageController,
          itemBuilder: (context, i) {
            ...
          },

          onPageChanged:(index) {
            setState(() {
              _pageNotifier.value = index;
            });
          },
        ),
        Center(
          child: CirclePageIndicator(
            currentPageNotifier: _pageNotifier,
            itemCount: totalCards.toInt(),
          ),
        )
      ],
    );
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter PageView 移除页面指示器 - Flutter PageView remove page Indicator 在带有点指示器的颤动中使用 PageView,在滑动每个页面时也需要更改按钮,就像在 ninjacart 应用程序中一样 - Using PageView in flutter with dot indicator, on swiping every page need to change the button also just like in ninjacart app 颤抖的Dots_Indicator PageView中的CurrentIndex不会更新 - CurrentIndex is not updated in the Dots_Indicator PageView in flutter (Flutter) 在 PageView 中自定义点指示器和动画 - (Flutter) Customize Dots Indicator and Animation in PageView PageView 指示点在 Persistent Bottomsheet Flutter 中不起作用 - PageView indicator dots not working in Persistent Bottomsheet Flutter Flutter:ListView 中带有点指示器的 PageView 不起作用 - Flutter: PageView with dots Indicator in ListView does not work 如何获取要在 Flutter 中的线条指示器中使用的 Pageview 中的页数? - How to Get the Number of Pages in Pageview to be used in a line indicator in Flutter? Flutter 水平列表视图点指示器 - Flutter Horizontal List View Dot Indicator 如何在 flutter 中使用点指示器创建图像 slider? - How to create image slider with Dot Indicator in flutter? 如何在Flutter Tabs中添加圆点作为指标? - How to add a circular dot as an indicator in Flutter Tabs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM