首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >下划线ListTile

下划线ListTile
EN

Stack Overflow用户
提问于 2022-03-07 15:03:19
回答 2查看 725关注 0票数 1

下面的代码负责显示设备的特性(为了便于演示,我缩短了代码,但问题的本质是可见的)。这很简单。告诉我如何添加我在照片中用红色标出的线条。正是这个长度,和文本的这个距离。

代码语言:javascript
复制
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 ))),
                        ],),)))));}}

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-03-07 15:18:49

您可以在Divider小部件之间使用ListTile

代码语言:javascript
复制
ListTile(..),
Divider(color: Colors.red, endIndent: 16, indent: 16), // THIS
ListTile(...)

即使在ListTile上使用了Transform.translate之后,它也会得到一些空间,但是我们可以在Divider上使用Transform.translate

代码语言:javascript
复制
Transform.translate(
    offset: Offset(0, -18), //adjust based on your need
    child: Divider(...)

如果您使用Container作为分隔符,则还将得到transfom

代码语言:javascript
复制
Container(
  transform: Matrix4.translationValues(0, -16, 0),
   ....
),

更多关于Transform.translate的信息。您还可以查看ListView.separated

票数 1
EN

Stack Overflow用户

发布于 2022-03-07 15:37:19

我们也可以使用带有颜色的Container

代码语言:javascript
复制
   Container(height: 1, color: Colors.grey)

喜欢

代码语言:javascript
复制
 ListTile(
        leading: Icon(Icons.home),
        title: Text('Home'),
 ),
 Container(height: 1, color: Colors.grey), //divider
 ListTile(
        leading: Icon(Icons.logout),
        title: Text('Logout'),
 ),

Dividercupertino.dart中不可用。因此,即使在这方面,我们也可以在ListView.separated中使用相同的容器技术

代码语言:javascript
复制
 ListView.separated(
   itemCount: 100,
   itemBuilder: (context, index) {
     return row;
   },
   separatorBuilder: (context, index) {
     return Container(
             height: 1,
             color: Styles.productRowDivider, // Custom style
           );
   },
 );
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71383046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档