如何更改material 按钮的字体大小.有没有更好的方法来做这件事?

new MaterialButton(
  height: 140.0,
  minWidth: double.infinity,
  color: Theme.of(context).primaryColor,
  textColor: Colors.white,
  child: new Text("material button"),
  onPressed: () => {},
  splashColor: Colors.redAccent,
),

推荐答案

Ffltter中的小部件体系 struct 使这一点变得非常简单:MaterialButton的子级是一个Text小部件,可以使用其style属性设置样式:

new MaterialButton(
  height: 140.0,
  minWidth: double.infinity,
  color: Theme.of(context).primaryColor,
  textColor: Colors.white,
  child: new Text(
    "material button",
    style: new TextStyle(
      fontSize: 20.0,
      color: Colors.yellow,
    ),
  ),
  onPressed: () => {},
  splashColor: Colors.redAccent,
);

Flutter相关问答推荐

我遇到了一个问题,从showDialogue()调用Navigator.pop()两次导致屏幕空白

Flutter 对齐:不适用于多行文字

升级到Ffltter 3.16后,应用程序栏、背景 colored颜色 、按钮大小和间距都会发生变化

如何在抖动中将PNG图像转换为WebP

FittedBox叠加技术在Flutter 中的应用

在flutter中实现类似3D的可滚动堆叠分页列表

如何使用 Material3 创建带有高度的完美白色提升按钮?

通过在父窗口小部件功能上设置状态来浏览屏幕

如何正确地将 PageView 设置为 AppBar 的标题?

使用堆栈的自定义按钮

将状态维护到 asyncNotifier

如何在 Flutter 中滚动时为多个小部件设置动画

Flutter - 定义按钮的优雅方式

容器在发布模式下显示灰色框(抖动)

String类型不是Widget类型的子类型?在dart 中

如何从 showModalBottomSheet 中的 topRight 和 topLeft 移除平边

为什么 orientation == Orientation.portrait 总是正确的,尽管我的设备已经处于横向

如何按键在 map 列表中搜索

使用 Firebase/Flutter 进行应用判断 - 100% 无效请求

Flutter 平台通道将多数据传递给 windows 功能