使 children 不在列表视图中滚动

make a children not scroll inside listview

我制作了一个 Column 小部件,其中包含一些 Row ,最后我得到了一个 ListView 小部件,它显示了一些像素错误,所以我改变了ColumnListView 并且像素错误消失了,但我需要 ListView 内的第一个 child 处于固定位置。请帮忙。下面的代码是示例。

SafeArea(
   child: ListView(
     children: [
       Row(),
       Row(),
       Row(),
       Row(),
       Row(),
       Row(),
     ]
   )
 )

这里是您可以执行的操作的示例,在 Column 中输入 ListView 并将要固定的小部件放在其上方,然后将 ListView 包裹在 Expanded 中以防止溢出:

  Widget build(BuildContext context) {

    return Scaffold(
      body: Column(
        children: [
          Text('Title'),
          Expanded(
            child: ListView(
                children: [
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello'),
                  Text('Hello')
                ]
            ),
          ),
        ],
      ),
    );
  }