如何左右滚动ROW?

问题描述 投票:0回答:1

是否有可能使一个Row小部件的子项只显示X个子项并使小部件可滚动?

Here's an example screenshot

有什么建议?

flutter flutter-layout
1个回答
0
投票

您可以将listview放入具有特定SizedBoxheight小部件中,然后您应该配置列表以使其以水平方式滚动:

   SizedBox(
   width: MediaQuery.of(context).size.width  // This will make your list fill the screen horizontally
   height: 100.0 // you can edit it as you desire but it should be small to make the effect of scroll-able row
   child: listview.builder(
      scrollDirection: Axis.horizontal, //This will make your list scroll on the horizontal axis
      itemCount: 10.0,
      itemBuilder: (BuildContext content, int index) {

      // Your itemBuilder code here

      }
    ),
  ),
© www.soinside.com 2019 - 2024. All rights reserved.