简体   繁体   English

如何为 Appbar 上的开关添加填充?

[英]How to add padding to a switch on an Appbar?

So I added a switch to my leading in my app bar.所以我在我的应用栏中添加了一个切换到我的领先地位。 It added a left padding by default.默认情况下它添加了一个左填充。 Problem is this padding doesn't match the rest of my body.问题是这个填充与我身体的 rest 不匹配。 I tried to wrap the switch with padding but it messed up the switch's track.我试图用填充包裹开关,但它弄乱了开关的轨道。 How to add padding to a switch on an Appbar?如何为 Appbar 上的开关添加填充?

Basically it should work if you wrap it in a SizedBox .基本上,如果您将其包装在SizedBox中,它应该可以工作。 Then you can controll the Padding and size of it.然后你可以控制它的填充和大小。 With that the Switch will loose the default padding which was applied.这样,Switch 将失去应用的默认填充。

SizedBox(
    height: 24.0,
    width: 24.0,
    child: (...),
 )
AppBar(
   leading: Switch(),
   titleSpacing: 0.0, //Use this how u like
   title: Text(""),
 ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM