flutter 如何删除两个ListTile之间的默认间距

6ss1mwsb  于 2023-02-13  发布在  Flutter
关注(0)|答案(3)|浏览(297)

列(子列:[列表平铺(视觉密度:视觉密度(水平:0,垂直:3),内容填充:const EdgeInsets.对称(水平:0.0,垂直:0.0),//内容填充:仅边缘插入(左: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
              ),),
          )
        ],
      ),

我在列中添加了两个列表块,但两个列表块之间没有空格

ca1c2owp

ca1c2owp1#

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,

          ),

        ],
      ),
ffdz8vbo

ffdz8vbo2#

可以使用contentPadding属性删除填充,将此属性设置为

ohtdti5x

ohtdti5x3#

你可以用sizedbox Package 你的列表或者在视觉密度上使用负值

children: [
        SizedBox(
          height: 45,
          child: ListTile(
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),
            ),
          ),
        ),
        SizedBox(
            height: 45,
              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),
              ),
            ))
      ],
    );

or use negative value in visual density

Column(
      children: [
        ListTile(
          visualDensity: VisualDensity(horizontal: 0, vertical: -4),
          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: -4),
          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),
          ),
        )
      ],
    );

相关问题