flutter - 如何更改 TextButton flutter 上的字体大小

标签 flutter flutter-layout font-size

这里你会改变这个例子中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/

相关文章:

firebase - 未定义类 'FirebaseUser'

flutter - 如何在 Flutter 上生成具有不同随机起点的随机模糊渐变颜色背景?

webview - 如何使用flutter dart webview渲染本地HTML文件

css - 为什么 IE9/Firefox 显示的字体大小与其他浏览器不同?

javascript - 使用 jQuery 设置随机值的字体大小?

Flutter - 重启倒计时定时器

flutter - 在Flutter应用程序中避免使用OpenStreetMap在flutter_map上留空白

flutter - 如何在 flutter 中绘制动态高度线?

flutter - 如何在 Flutter 的 Scaffold.drawer 中保持小部件的状态?

android - TextView字体大小根据不同的分辨率和屏幕大小