问题描述
当使用ListView的时候发现,顶部有块默认的Padding,如下图所示
![](https://img.haomeiwen.com/i8850933/dfbe9d6cbe325132.png)
解决方法
使用MediaQuery.removePadding来删除默认的Padding,如下所示:
MediaQuery.removePadding(
context: context,
removeTop: true,
removeBottom: true,
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 2,
itemBuilder: (context, index) {
return Container(
height: 50,
color: Colors.white,
child: Row(
children: [
Text("测试1", style: TextStyle(color: Colors.black)),
Text("离线", style: TextStyle(color: Colors.grey,fontSize: 14))
],
),
);
},
),
)
![](https://img.haomeiwen.com/i8850933/23ff3b5d2915cd32.png)
网友评论