我有一个OutlineButton,在这里我尝试使用Google字体来处理文本,使用google-fonts依赖项。代码看起来如下:
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
}),虽然我指定白色作为文本的颜色,但文本显示为蓝色。
我在这里错过了什么?为什么“下一个”文本不以白色出现?

发布于 2022-01-20 09:32:36
不需要更改按钮textStyle只需更改子textSytle
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
})预览

https://stackoverflow.com/questions/70783575
复制相似问题