如何缩小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
相关产品推荐
相关产品推荐

