这里你会改变这个例子中Hello World的字体大小吗? 尝试了字体样式等,但出现错误,我缺少什么?
new TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.white.withOpacity(0.7)),
overlayColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.focused) ||
states.contains(MaterialState.pressed))
return Colors.red.withOpacity(0.7);
return Colors.red;
return Colors.white70; // Defer to the widget's default.
}
),
),
child: new Text('Hello World'),
最佳答案
请尝试一下
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(
Colors.white.withOpacity(0.7)),
overlayColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.focused) ||
states.contains(MaterialState.pressed))
return Colors.red.withOpacity(0.7);
return Colors.red; // Defer to the widget's default.
return Colors.white70;
}),
),
child: new Text('Hello World', style: TextStyle( fontSize: 30),),
)
关于flutter - 如何更改 TextButton flutter 上的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67985910/