我做了一个Column
小部件,里面包含一些Row
,最后我得到了一个ListView
小部件,它显示了我一些像素错误,所以我把Column
改成了ListView
,像素错误消失了,但是我需要ListView
里面的第一个孩子在固定的位置。请帮助。下面的代码是示例。
SafeArea(
child: ListView(
children: [
Row(),
Row(),
Row(),
Row(),
Row(),
Row(),
]
)
)
这里有一个例子,你可以这样做,在列中输入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')
]
),
),
],
),
);
}