flutter - Flutter:如何在 Flutter 的构建函数中添加“if”逻辑
问题描述
我在构建函数中有以下内容,我只希望它显示逻辑是否正确
if (!isKeyBoardVisible)
SizedBox(height: 13.0),
buildApplyButton(),
SizedBox(height: 20.0,)
但是,上述语句仅适用于第一个尺寸框。
我怎样才能使它完整的3个语句
谢谢
解决方案
isKeyBoardVisible
? Column(
children: <Widget>[
SizedBox(height: 13.0),
buildApplyButton(),
SizedBox(
height: 20.0,
)
],
)
: Column(
children: <Widget>[
SizedBox(height: 13.0),
buildApplyButton(),
SizedBox(
height: 20.0,
)
],
)
: else 是三元运算符的一部分,你可以把你的 else 部分放在那里
推荐阅读
- javascript - Canvas quadraticCurveTo
- python-3.x - 如何从 API 中提取日志并将其存储在 AWS S3 中
- r - 如何在 R 中使用 foreach 并行查找来停止列表输出
- mongodb - 如何过滤 IsoDate 字段中的时间?
- python - 部分覆盖在其父级范围之外的小部件
- node.js - 如何自定义从 Express 发送的 Mongoose/MongoDB 错误
- amazon-web-services - AWS S3 存储桶图像 - React Native 应用程序一直显示旧图像
- r - 我们如何知道随机 R 脚本中的 dev.size 单位?
- sql - 有时 SQL Server 选择查询太慢
- windows - 如何解释 ETW 图的采样和精确 CPU 使用率,当它们相互矛盾时