我有一个listview builder低于我的分隔符,但当我把我的listview builder低于分隔符.它会显示一个大的大空白空间,我试图添加填充,但不能推动它更接近分隔符.我试图改变分隔符的高度,但它不推动分隔符到我的listview.
有什么想法让分隔符和列表视图构建器更接近彼此吗?
Widget myWidgetWeek() {
final String formattedDate =
DateFormat.yMMMMd().format(_selectedDate);
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: _decrementDate,
icon: Icon(Icons.arrow_left, size: 60),
),
Container(
padding: EdgeInsets.only(left: 22,top: 20),
height: MediaQuery.of(context).size.height*5/77,
child: Center(
child: Text(
formattedDate,
style: TextStyle(fontSize: 20.0),
),
),
),
IconButton(
onPressed: _incrementDate,
icon: Icon(Icons.arrow_right, size: 60),
),
],
),
SizedBox(
width: MediaQuery.of(context).size.width * 34/40,
height: MediaQuery.of(context).size.height * 12/50,
child: StepBarMonthlyChart(),
),
if (_showFirst)
Container(
width: MediaQuery.of(context).size.width*5/5.7,
padding: EdgeInsets.only(top: 10.0,left: 10),
child: Text(
'Steps are a useful measure of how much you\'re moving around, and can help you'
'spot changes in your activity levels',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w400),
),
),
if (_showFirst)
Divider(
height: MediaQuery.of(context).size.height * 3.5/50,
color: Colors.grey,
thickness: 2,
),
if (_showFirst)
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: activity.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(activity[index]['day']),
subtitle: Text(activity[index]['steps']),
);
},
),
),
],
);
}
4条答案
按热度按时间f1tvaqid1#
在ListTile中添加以下属性
希望这能帮上忙
uhry853o2#
1.设置填充:在listview.builder中的EdgeInsets.all(),我希望这可以帮助您解决这个问题
vmdwslir3#
这是我做ListView时的一个秘密bug,你只需要添加一个零填充即可:
希望能帮到你!
ecfsfe2w4#
删除分隔器的高度
然后使用SizedBox或Padding给予间距。