【问题标题】:How to make a ListView or PageView with Circle Items in Flutter and resizing the current Circle bigger?如何在 Flutter 中使用 Circle Items 制作 ListView 或 PageView 并调整当前 Circle 的大小?
【发布时间】:2020-03-28 19:08:23
【问题描述】:

【问题讨论】:

    标签: android listview flutter dart


    【解决方案1】:
     //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,
            ),
    

    【讨论】:

    • 您的意思是 index == selectedPage 而不是 position == selectedPage 吗?
    • 是的!对不起!
    猜你喜欢
    • 1970-01-01
    • 2023-03-25
    • 2019-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-18
    • 1970-01-01
    • 2023-01-30
    相关资源
    最近更新 更多