flutter - 卡borderOnForeground 未按预期工作
问题描述
代码:
Card(
color: Colors.blue,
borderOnForeground: false, // doesn't do anything on true also
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(300)),
child: Container(
width: 200,
height: 200,
color: Color(0x30FF0C5C),
child: Text(
"|||||||",
style: TextStyle(fontSize: 40),
),
),
)
文档说:
borderOnForeground:是否在[child]前面绘制[shape]边框。默认值是true。如果为 false,则边框将绘制在 [child] 的后面。
输出:
问题:
我希望白色垂直线在默认情况下(何时borderOnForeground: true
)位于蓝色圆圈内,但它不会这样做,也不会将其设置为false
. 那么borderOnForeground
实际上是做什么的呢?
笔记:
我知道有很多方法可以实现我所要求的使用ClipRRect
等ClipOval
。我不是在寻找那些解决方案,我只是想知道是什么borderOnForeground
?
解决方案
问题是你没有边框(就像在 CSS 中一样),这就是为什么true
看起来false
一样。要查看差异,请添加粗边框:
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(300.0),
),
side: BorderSide(
color: Colors.red,
width: 20.0,
),
),
如果您将borderOnForeground: false
卡片的孩子的部分设置在红色边框下方,现在将在它上方。
推荐阅读
- php - 如何编辑具有相同键的数组组合的这个foreach循环?
- c++ - NOEXCEPT 之前的预期初始化程序
- typo3 - 使用 TYPO3 存储库查询获取禁用/隐藏的关系表记录
- php - Laravel/PHP 重构代码以使用相同的不同模式
- c# - 检查是否从 Checkchanged 事件中检查了 RadioButton
- amazon-web-services - 为什么使用 terraform 创建 API 网关的方法响应不同?
- google-tag-manager - 在跟踪代码管理器中多次触发事件
- r - 如何在R中以0小数舍入百分比
- linux - 访问某些 index.php 或 index.html 时出现 Apache 403 错误,尽管每个 index.php 或 index.html 具有相似的权限
- java - Hazelcast EntryProcessor ClassNotFoundException