【问题标题】:How to remove Default space between Two ListTile如何删除两个 ListTile 之间的默认空间
【发布时间】:2023-02-10 19:34:19
【问题描述】:

柱子( 孩子们: [ 列表块( 视觉密度:视觉密度(水平:0,垂直:3), contentPadding: const EdgeInsets.symmetric(水平: 0.0, 垂直: 0.0), //contentPadding: E​​dgeInsets.only(左: 0.0, 右: 0.0),

            leading: IconButton(
              onPressed: (){},
              icon:const Icon(Icons.location_on_outlined,size: 40,) ),
              title: GestureDetector(
                onTap: (){
    
                },
                child: const Text("PICK UP",style: TextStyle(
                  fontSize: 19,
                  fontWeight: FontWeight.w500,
                  color:Color.fromARGB(255, 152, 182, 55)
                ),)
                ),
              subtitle:const Text("Mysore,",style: TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: Colors.black
              ),),
          ),
          
          ListTile(
            visualDensity: VisualDensity(horizontal: 0, vertical: 3),
            contentPadding: const EdgeInsets.symmetric(horizontal: 0.0, vertical:0),
            
            leading: IconButton(
              onPressed: (){},
              icon:const Icon(Icons.location_on_outlined,size: 40,) ),
              title: GestureDetector(
                onTap: (){
    
                },
                child: const Text("DROP OFF",style: TextStyle(
                  fontSize: 19,
                  fontFamily: "Ubuntu",
                  fontWeight: FontWeight.w500,
                  color:Color.fromARGB(255, 152, 182, 55)
                ),)
                ),
              subtitle:const Text("Bangalore,",style: TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.w500,
                color: Colors.black
              ),),
          )
        ],
      ),

我在列中添加了两个 listtile,但我不希望两个 ListTile 之间有空格

【问题讨论】:

  • 瓷砖之间没有空间。你想让他们不那么高?尝试离开 visualDensity 或给 vertical 一个负值

标签: flutter list dart flutter-dependencies


【解决方案1】:
Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          SizedBox(height: 5),
          ListTile(
            visualDensity: VisualDensity(horizontal: 0, vertical: -2),
            contentPadding: const EdgeInsets.symmetric(horizontal: 0.0, vertical: 0),
            leading: IconButton(
                onPressed: () {},
                icon: const Icon(Icons.location_on_outlined, size: 40,)),
            title: GestureDetector(
                onTap: () {},
                child: const Text(
                  "DROP OFF",
                  style: TextStyle(
                      fontSize: 19,
                      // fontFamily: "Ubuntu",
                      // fontWeight: FontWeight.w500,
                      color: Color.fromARGB(255, 152, 182, 55)
                  ),
                )),
            subtitle: const Text(
              "Bangalore,",
              style: TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                  color: Colors.black),
            ),tileColor: Colors.yellow,
            dense: true,

          ),
          ListTile(
            visualDensity: VisualDensity(horizontal: 0, vertical: -2),
            contentPadding: const EdgeInsets.symmetric(horizontal: 0.0, vertical: 0),
            leading: IconButton(
                onPressed: () {},
                icon: const Icon(Icons.location_on_outlined, size: 40,)),
            title: GestureDetector(
                onTap: () {},
                child: const Text(
                  "DROP OFF",
                  style: TextStyle(
                      fontSize: 19,
                      // fontFamily: "Ubuntu",
                      // fontWeight: FontWeight.w500,
                      color: Color.fromARGB(255, 152, 182, 55)
                  ),
                )),
            subtitle: const Text(
              "Bangalore,",
              style: TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                  color: Colors.black),
            ),tileColor: Colors.yellow,
            dense: true,

          ),

        ],
      ),

【讨论】: