我有一个问题,我想为我的抽屉列表项目创建边框和圆形框。我可以创建边框和圆形框,但问题是文本和图标与周围框之间的空间太大。
我尝试过几种纯粹使用容器、容器和列表图块的方法,它们都给出了相同的结果。我也试过在垫子周围玩耍。
以下是不同的编码。

Column(children: <Widget>[
       //Padding(padding:const EdgeInsets.fromLTRB(15, 0, 10, 10)),
       Container(
         height: 55,
        padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
        margin: EdgeInsets.symmetric(vertical: 10.0),

        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(6.0),
          border: Border.all(color: Colors.black),
        ),

        child: Column(
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[

                      IconButton(
                        icon: Icon(Icons.map),
                        onPressed: () => {},
                      ),
                      Padding(padding: EdgeInsets.only(left: 20.0)),
                      Text("TEST"),
                    ],
                  ),
          ]
        ),
       ),
       Container(
       margin: const EdgeInsets.fromLTRB(5, 0, 5, 5),
       alignment: Alignment.bottomRight,


       child: ListTile(
            leading: new Icon(Icons.map),
            title: Text("Map View"),
            trailing: Icon(Icons.arrow_forward),

          ),
       decoration: BoxDecoration(

        color: getColor(title,"Dashboard"),
        borderRadius: BorderRadius.only(
            topLeft: Radius.circular(8.0),
            topRight: Radius.circular( 8.0),
            bottomLeft: Radius.circular( 8.0),
            bottomRight: Radius.circular( 8.0),
        )
        ),

        ),
        Ink(
          color: getColor(title,"Dashboard"),
          child: ListTile(
            leading: new Icon(Icons.map),
            title: Text("Map View"),
            trailing: Icon(Icons.arrow_forward),

          ),
        ),
         Padding(padding:const EdgeInsets.fromLTRB(5, 0, 10, 10)),
        ListTile(
          leading: new Icon(Icons.map),
          title: Text("Map View"),
          trailing: Icon(Icons.arrow_forward),

        ),
        ListTile(
          leading: new Icon(Icons.map,color: Colors.blue,),
          title: Text("List View"),
          trailing: Icon(Icons.arrow_forward),

        ),
      ],
)

我也附上了图片输出。我更喜欢第二个选项,但盒子和单词的空间太大?flutter - 如何删除文本或列表瓷砖和框装饰边框之间的空间?-LMLPHP
flutter - 如何删除文本或列表瓷砖和框装饰边框之间的空间?-LMLPHP
这是我的最新密码。
列(子级:[
          Container(

padding: EdgeInsets.all(5.0),
                  margin: EdgeInsets.symmetric(vertical: 10.0),

                  decoration: BoxDecoration(
                    color: getColor(title,"Dashboard"),
                    borderRadius: BorderRadius.circular(6.0),
                    border: Border.all(color: Colors.amber),
                  ),
                  child:Row(children: <Widget>[
                    Icon(Icons.map),
                      SizedBox(width: 10),
                      Text("Map View"),
                      Expanded(child: Container (),),
                      Icon(Icons.arrow_forward),]
                      )

        ),
        Container(

padding: EdgeInsets.all(5.0),
                  margin: EdgeInsets.symmetric(vertical: 10.0),

                  decoration: BoxDecoration(
                    color: getColor(title,"Dashboard"),
                    borderRadius: BorderRadius.circular(6.0),
                    border: Border.all(color: Colors.amber),
                  ),
                  child:Row(children: <Widget>[
                    Icon(Icons.map),
                      SizedBox(width: 10),
                      Text("Map View"),
                      Expanded(child: Container (),),
                      Icon(Icons.arrow_forward),]
                      )

        ),
        ]),

最佳答案

您可能希望删除ListTile以支持自定义的Row

Row(children: [
Icon(Icons.map),
SizedBox(width: 10),
Text("Map View"),
Expanded(child: Container (),),
 Icon(Icons.arrow_forward),])

(不好意思我在电话里打这个时把密码弄乱了。)
有了这个,您可以更好地控制填充以及行中小部件之间的空间大小。

关于flutter - 如何删除文本或列表瓷砖和框装饰边框之间的空间?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57436312/

10-09 03:39