我正在创建一个应用内电子邮件收件箱,并希望为ListTile中前导图标的背景着色。如何填充前导属性,以使图标上下有间距?
过去,我尝试将ListTile的contentpadding设置为0.0,以及将Container的padding设置为0.0。
请查看下面的代码:
Widget buildItem(LeaveBehindItem item) {
final ThemeData theme = Theme.of(context);
return new Dismissible(
key: new ObjectKey(item),
direction: _dismissDirection,
onDismissed: (DismissDirection direction) {
setState(() {
leaveBehindItems.remove(item);
});
final String action = (direction == DismissDirection.endToStart) ? 'archived' : 'deleted';
_scaffoldKey.currentState.showSnackBar(new SnackBar(
content: new Text('You $action item ${item.index}'),
action: new SnackBarAction(
label: 'UNDO',
onPressed: () { handleUndo(item); }
)
));
},
background: new Container(
color: Colors.green,
child: const ListTile(
leading: const Icon(Icons.done, color: Colors.white, size: 36.0)
)
),
secondaryBackground: new Container(
color: Colors.orange,
child: const ListTile(
trailing: const Icon(Icons.query_builder, color: Colors.white, size: 36.0)
)
),
child: new Container(
padding: EdgeInsets.all(0.0),
decoration: new BoxDecoration(
color: theme.canvasColor,
border: new Border(bottom: new BorderSide(color: theme.dividerColor))
),
child: new ListTile(
contentPadding: EdgeInsets.all(0.0),
leading: Container(
decoration: BoxDecoration(color: Colors.grey[500]),
child: Icon(Icons.lightbulb_outline, size: 50.0,),
),
title: new Text(item.name),
subtitle: new Text('${item.subject}\n${item.to}\nHas been read: ${item.read}'),
onTap: () async {
await Navigator.push(context, MaterialPageRoute(builder: (context) => EmailBody(item: item)));
item.read = true;
},
)
)
);
}