在 ListTile 中放置两个尾随图标 [英] Placing two trailing icons in ListTile

查看:14
本文介绍了在 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)
          ]),
        )
      ]
    ),
      ),
    );
  }
}

看起来是这样的:

推荐答案

mainAxisSize: MainAxisSize.min 添加到 Row() 实例可以解决问题.

Adding mainAxisSize: MainAxisSize.min to the Row() instance fixes the issue.

这篇关于在 ListTile 中放置两个尾随图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆