Flutter如何使用ListTile Threeline

2024-05-02

Flutter时使用ListTile ThreeLines,不知道如何使用ThreeLine

    import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text('ddd'),
        ),
        body:Container(
        child: Column(
          children: <Widget>[
            ListTile(
              isThreeLine: true,
              leading: Icon(Icons.event_note),
              title: Text('Title 1'),
              // subtitle: Text('Title2'),
              subtitle: Column(

                children: <Widget>[
                  Text('Titile2'),
                  Text('Title 3'),
                  Text('Title 4'),
                  Text('and so on')
                ],
              ),

            )
          ],
        ),
      ) ,
      ),

    );
  }
}

当我删除 isThreeLines 时,代码是好的

ListTile https://docs.flutter.io/flutter/material/ListTile/isThreeLine.html

Thanks


从文档来看: https://docs.flutter.io/flutter/material/ListTile-class.html

subtitle的值是可选的,会占用空间 分配额外的文本行,或者如果 isThreeLine 则分配两行 是真的。

它基本上意味着subtitle of the ListTile被给予更多的空间来容纳长度超过一行的文本:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Flutter如何使用ListTile Threeline 的相关文章

随机推荐