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

如何为调用showLicensePage后出现的进度指示器自定义样式?

自定义showLicensePage圆形进度指示器颜色的实现方法

可以实现,showLicensePage会继承传入context对应的主题配置,只需在调用位置外层嵌套自定义Theme覆盖进度指示器的主题属性即可,修改后的代码如下:

OutlinedButton(
    onPressed: () {
        Theme(
            data: Theme.of(context).copyWith(
                // 自定义圆形进度指示器颜色
                progressIndicatorTheme: const ProgressIndicatorThemeData(
                    color: Colors.green, // 替换为你需要的目标颜色
                ),
                // 如需修改许可证页面其他样式,可在此处补充其他Theme配置项
            ),
            child: Builder(
                builder: (context) {
                    showLicensePage(
                      context: context,
                      applicationIcon: const MyAppIcon(48),
                    );
                    return const SizedBox.shrink();
                },
            ),
        );
    },
    child: Text(
        AppLocalizations.key(context, 'licenses'),
    ),
),

如果需要全局修改所有页面的进度指示器颜色,直接在项目根MaterialApp的theme参数中配置progressIndicatorTheme即可,无需在调用处单独嵌套Theme。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 21:06:01