本文介绍了在ListTile中放置两个尾随图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在ListTile的尾随"侧并排放置两个图标.我尝试添加带有两个图标的Row小部件,但是它完全弄乱了整个ListTile的布局,使其无法使用.有什么方法可以扩展为尾部分配的空间吗?
I want to place two icons, side by side on the "trailing" side of a ListTile. I tried adding a Row widget with the two icons inside, but it completely messed up the layout of the entire ListTile, making it unusable. Is there any way to expand the space allocated for the trailing part?
代码如下:
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
body: ListView(
children: <Widget>[
ListTile(
leading: Icon(Icons.play_arrow,),
title: Text("This is a title"),
subtitle: Text("This is subtitle"),
trailing: Row(
children: <Widget>[
Icon(Icons.flight),
Icon(Icons.flight_land)
]),
)
]
),
),
);
}
}
它是这样的:
推荐答案
在Row()实例中添加 mainAxisSize:MainAxisSize.min
可解决此问题.
Adding mainAxisSize: MainAxisSize.min
to the Row() instance fixes the issue.
这篇关于在ListTile中放置两个尾随图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!