首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google字体颜色被忽略

Google字体颜色被忽略
EN

Stack Overflow用户
提问于 2022-01-20 09:18:46
回答 1查看 307关注 0票数 0

我有一个OutlineButton,在这里我尝试使用Google字体来处理文本,使用google-fonts依赖项。代码看起来如下:

代码语言:javascript
复制
OutlinedButton(
  child: const Text('Next'),
  style: ButtonStyle(
    backgroundColor: MaterialStateProperty.resolveWith((states) {
      return colorPrimaryButton;
    }),
    textStyle: MaterialStateProperty.resolveWith((states) {
      return GoogleFonts.inter(textStyle: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white));
    })
  ),
  onPressed: () {
    // do something
  }),

虽然我指定白色作为文本的颜色,但文本显示为蓝色。

我在这里错过了什么?为什么“下一个”文本不以白色出现?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-20 09:32:36

不需要更改按钮textStyle只需更改子textSytle

代码语言:javascript
复制
OutlinedButton(
                  child: Text(
                    'Next',
                    style: GoogleFonts.inter(
                        textStyle: const TextStyle(
                            fontSize: 20,
                            fontWeight: FontWeight.bold,
                            color: Colors.white)),
                  ),
                  style: ButtonStyle(
                    backgroundColor: MaterialStateProperty.resolveWith((states) {
                      return Colors.indigo;
                    }),
                  ),
                  onPressed: () {
                    // do something
                  })

预览

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70783575

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档