【问题标题】:flutter container with different vertical spacings by the same contents以相同的内容颤动具有不同垂直间距的容器
【发布时间】:2020-12-17 12:30:48
【问题描述】:

我在两个内容相同的容器中有不同的垂直间距。我用不同的小部件尝试过它,它总是一样的。 “卡片”小部件包含一个带有两个相同“容器”的“列”,每个容器包含一个相同的“ListTile”和一个相同的“子项:文本”。 如何使垂直距离相等且尽可能小?

  Container(
width: screenWidth * 0.5, height: 300,
padding: EdgeInsets.all(10),
child: Column(
   children: <Widget>[
     Container(
       width: screenWidth * 0.5, height: 280,
       padding: EdgeInsets.all(1),

       child: Card(
           shape: RoundedRectangleBorder(
             borderRadius: const BorderRadius.all(Radius.circular(8.0),),
             side: BorderSide(
               color: Colors.black,
               width: 1.0,),
           ),
           color: Colors.white,
           elevation: 4.0,
           shadowColor: Colors.blue,
           child: Column(
             mainAxisAlignment: MainAxisAlignment.start,

             children:[
              Container(
                padding: EdgeInsets.all(0.0),
                margin: EdgeInsets.all(0.0),
                decoration: BoxDecoration(
                  color: Colors.yellow,
                  border: Border.all(color: Colors.black),
                ),
                   child: ListTile(
                     
                       contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 5.0),
                       dense: true,
                       isThreeLine: false,

                       title: Text(
                         selTitle,
                         style: TextStyle(
                           color:Colors.black,
                           //backgroundColor: Colors.limeAccent,
                           backgroundColor: selColor(selIndex),
                           fontSize: 20,
                           fontWeight: FontWeight.bold,
                         ),
                       )
                   )
                ),

                Container(
                   padding: EdgeInsets.all(0.0),
                   margin: EdgeInsets.all(0.0),
                   decoration: BoxDecoration(
                     color: Colors.yellow,
                     border: Border.all(color: Colors.black),
                   ),
                   child: ListTile(
                     
                     contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 5.0),
                     dense: true,
                     isThreeLine: false,
                     title: Text(
                         "noch ein sehr langer Text: jihiuwh  uewua8h ieshg lisru hirluh spi",
                         style: TextStyle(
                           backgroundColor: myBTN_HELLGRAU,
                           fontSize: 16,
                         )
                     ),
                   )
              )

             ]

           )
       ),
     )
  ]
)

),

see detailshere is the whole application

“安道尔”中的垂直距离远大于下面的文字。 如何使上部字段中的间距变小?

【问题讨论】:

  • 但我不知道为什么

标签: flutter-layout dart-pub


【解决方案1】:

我找到了解决办法。插入第一个 ListTile 解决了我的问题:

visualDensity: VisualDensity(horizontal: 0, vertical: -4),

【讨论】:

    猜你喜欢
    • 2016-12-19
    • 2014-08-03
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多