Flutter when I used ListTile ThreeLines, I don't know how to use 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')
],
),
)
],
),
) ,
),
);
}
}
When i delete isThreeLines, the code is Ok
ListTile
Thanks
Just give it some constraints (eg. by wrapping in a SizedBox with a width ) or, if you want to take it as much space as possible, just wrap each ListTile with a Flex widget such as Flexible or Expanded if you want to share space evenly with all tiles on that Column .
To add or change the ListTile border color, add the shape parameter with RoundedRectangleBorder() inside the ListTile widget. Inside the RoundedRectangleBorder widget, add the side property and assign the BorderSide(width: 2, color: Colors. amberAccent).
To add the divider between ListTile items, add the ListView widget. Inside ListView , add the ListTile. divideTiles with the tiles property and a list of ListTiles.
As from the docs:
The value of subtitle, which is optional, will occupy the space allocated for an additional line of text, or two lines if isThreeLine is true.
It basically means the subtitle
of the ListTile
is given more space to have text which is more than one line in length:
By default, the ListTile in flutter can display only 2 lines. The Title and the SubTitle. In case there is a third line of text to be displayed, the isThreeLine is set to true and can allow another line to be present. The subtitle will be taking care of giving the 3rd line of text. It is expected that, if the isThreeLine is set to true, the subtitle should be non-null. Anything after "\n" inside subtitle will come in next line
ListTile(
title: Text("First Line",
style: TextStyle(fontWeight: FontWeight.bold)),
subtitle: Text("Second One Text "\nThis is Line Third Text"),
isThreeLine: true,
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
GestureDetector(
child: Icon(Icons.delete,color: Colors.red,),
onTap: () {
},
),
],
),
onTap: (){},
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With