简体   繁体   English

如何在 Flutter 中使用 Circle Items 制作 ListView 或 PageView 并调整当前 Circle 的大小?

[英]How to make a ListView or PageView with Circle Items in Flutter and resizing the current Circle bigger?

Something like this: https://i.gyazo.com/2d60f65a1801eaaa58bcb1e795f7edec.png with circles.像这样: https : //i.gyazo.com/2d60f65a1801eaaa58bcb1e795f7edec.png带圆圈。 Is it also possible to do something like this https://gyazo.com/f58e4c5db30013a832b70a839fdc1c03 ?是否也可以做这样的事情https://gyazo.com/f58e4c5db30013a832b70a839fdc1c03

 //declare these
 PageController _pageController = PageController(viewportFraction: 0.5);
 int selectedPage = 0;
 List yourList =[];


 //in initState method
    _pageController.addListener(() {
      setState(() {
        selectedPage = controller.page;
      });
    });

  //inside body

     PageView(
          controller: _pageController,
          itemBuilder: (context, index) {
            if (index == selectedPage) {
               Container(
                  alignment: Alignment.center,
                  height:300.0,
                  width:300.0,
                  child: CircleAvatar(
                         backgroundImage: yourList[index],
                       //modify as you want
                      )
                )
            }
             else {
              Container(
                  alignment: Alignment.bottom,
                  height:100.0,
                  width:100.0,
                  child: CircleAvatar(
                         backgroundImage: yourList[index],
                       //modify as you want
                      )
            }
          },
          itemCount: yourList.length,
        ),

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM