flutter - 在 RaisedButton 内放置一个 CircularProgressIndicator 保持大小
问题描述
我想将 aCircularProgressIndicator
放在a 内RaisedButton
,但是当我这样做时, aCircularProgressIndicator
不适合按钮并伸出它。
我想缩小CircularProgressIndicator
,使其适合RaisedButton
,我知道我可以使用 aSizedBox
但我希望它是自动的,而不是我给它我想要的大小。我试过FittedBox
了,但它的所有选项都没有任何区别。
这是我的按钮代码:
RaisedButton(
onPressed: () => print('hi'),
shape: StadiumBorder(),
color: Theme.of(context).primaryColor,
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 12, top: 6, bottom: 6),
child: CircularProgressIndicator(
backgroundColor: Colors.white,
strokeWidth: 2,
),
),
Text('Loading'),
],
),
),
这就是它的样子:
当我添加Padding
它时,按钮会变大:
有没有办法自动实现这一点?
编辑:
为了清楚起见,我想要的最终效果是:
用户按下按钮之前和之后:
我希望高度自动保持不变,而SizedBox
.
解决方案
查看CircularProgressIndicator
源代码,我可以发现硬编码的最小尺寸为 36.0 高度/宽度,因此无法自动变小。
推荐阅读
- python - 检查是否在 python 中配置了 aws 凭据
- driver - 没有 I2C 的 MIPI
- reactjs - @tinymce/tinymce-react - 我如何改变代码的焦点?
- email - ICS 文件在从个人电子邮件发送时工作,但从 mandrill api 发送时不工作
- mongodb - 以嵌套形式显示 mongodb 文档而不更改数据库
- c# - 如何在 C# 中拆分 OData 多级展开查询字符串?
- azure - 使用 OAuth 令牌下载 blob 的 Azure 函数
- java - 打开的事务看不到另一个事务提交的数据
- prolog - Prolog动态预测不记得值
- mysql - 使用案例在哪里过滤不同的表?