'Underline ListTile
The following code is responsible for displaying the characteristics of the device (I shortened code for ease of demonstration, but the essence of my question is visible.). It's very simple. Tell me how to add the lines that I marked in the photo in red. Exactly this length, and exactly at this distance from the text.
return Scaffold(
body: Align(
alignment: Alignment.topCenter,
child: Container(
constraints: BoxConstraints(maxWidth: 800, maxHeight: 300),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(5.0),
),
child: SingleChildScrollView(
child: Card(
child: Column(
children: [
ListTile(
title: const Text('Brand:', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 25)),
trailing: Text('${device.brand} ', style: const TextStyle(fontWeight: FontWeight.w400, fontSize: 20 ))),
ListTile(
title: const Text('Operation system:', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 25)),
trailing: Text('${device.operation_system} ', style: const TextStyle(fontWeight: FontWeight.w400, fontSize: 20 ))),
],),)))));}}
Solution 1:[1]
We can also use Container with a color
Container(height: 1, color: Colors.grey)
like
ListTile(
leading: Icon(Icons.home),
title: Text('Home'),
),
Container(height: 1, color: Colors.grey), //divider
ListTile(
leading: Icon(Icons.logout),
title: Text('Logout'),
),
The Divider is not available in cupertino.dart. So even in that we can use the same Container technique with ListView.separated:
ListView.separated(
itemCount: 100,
itemBuilder: (context, index) {
return row;
},
separatorBuilder: (context, index) {
return Container(
height: 1,
color: Styles.productRowDivider, // Custom style
);
},
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

