【问题标题】:How to add multiple ListTile in end drawer without scrolling in flutter?如何在末端抽屉中添加多个 ListTile 而不会在颤动中滚动?
【发布时间】:2021-06-16 15:31:15
【问题描述】:

如何在不滚动的情况下在末端抽屉中添加多个(13 项)而不滚动

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies flutter-animation


    【解决方案1】:

    使用Expanded 小部件作为这些项目的父级并放置在Column 下。

    你的抽屉应该是这样的:

    Drawer(
      child: Column(
        children: [
          Container(), //Your Blue Section
          Expanded( // Item 1
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 16.00),
              Row(
                children: [
                  Icon(),
                  Text(),
                ],
              ),
            ),
          ),
          Expanded( // Item 1
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 16.00),
              Row(
                children: [
                  Icon(),
                  Text(),
                ],
              ),
            ),
          ),
          Expanded( // Item 2
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 16.00),
              Row(
                children: [
                  Icon(),
                  Text(),
                ],
              ),
            ),
          ),
          Expanded( // Item 3
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 16.00),
              Row(
                children: [
                  Icon(),
                  Text(),
                ],
              ),
            ),
          ),
          Expanded( // Item 4
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 16.00),
              Row(
                children: [
                  Icon(),
                  Text(),
                ],
              ),
            ),
          ),
          .
          . and so on ...
          .
        ]      
      )
    ),
    

    【讨论】:

    • 不客气。但是,市场上仍有小屏幕或分辨率较低的设备,因此您可能不希望抽屉项目看起来非常压缩,因此您应该考虑使其可滚动。
    【解决方案2】:

    将包含项目的列放在溢出小部件中

    
    OverflowBox(
      child : Column(
        children: [ 
             /// items 
          ]
       )
    )
    
    

    【讨论】:

      猜你喜欢
      • 2020-09-26
      • 1970-01-01
      • 1970-01-01
      • 2021-03-15
      • 2020-06-06
      • 1970-01-01
      • 1970-01-01
      • 2020-04-07
      • 1970-01-01
      相关资源
      最近更新 更多