You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何缩小TextFormField后缀图标中的CircularProgressIndicator?

解决方法

原来的代码没生效是因为CircularProgressIndicator自带默认尺寸约束,单纯用SizedBox包裹无法突破这个约束。试试这两种方法:

  • 方法一:用Transform.scale缩放
    通过缩放变换直接调整指示器的整体大小,灵活度高:
TextFormField(
  // 其他属性...
  decoration: InputDecoration(
    // 其他装饰属性...
    suffixIcon: Transform.scale(
      scale: 0.5, // 数值越小尺寸越小,根据需求调整
      child: const CircularProgressIndicator(),
    ),
  ),
)
  • 方法二:指定指示器的size和strokeWidth
    直接给CircularProgressIndicator设置strokeWidth(线条粗细)和size参数,再用SizedBox限制范围:
TextFormField(
  // 其他属性...
  decoration: InputDecoration(
    // 其他装饰属性...
    suffixIcon: const SizedBox(
      height: 16,
      width: 16,
      child: CircularProgressIndicator(
        size: 16, // 指示器整体大小
        strokeWidth: 2, // 线条粗细,配合size调整视觉效果
      ),
    ),
  ),
)

内容的提问来源于stack exchange,提问作者My Car

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 10:42:07