简体   繁体   English

Flutter 小部件内的条件填充

[英]Conditional padding inside Flutter widget

I see this answer for conditional color我看到了条件颜色的这个答案

I am trying to do the same for padding like so我正在尝试对填充做同样的事情

Padding(
  padding: const EdgeInsets.only(bottom: isLogin ? 58.0 : 10.0),
)

it is not being accepted.它不被接受。

Thank you谢谢

You can use it like this:你可以像这样使用它:

            padding: isLogin
                ? EdgeInsets.only(bottom: 58.0)
                : EdgeInsets.only(bottom: 10.0),

Edit:编辑:

or just remove const like this.或者像这样删除const

            padding: EdgeInsets.only(bottom: isLogin ? 58.0 : 10.0),

You can read the usage of const fromhere .您可以从这里阅读const的用法。

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

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