首页 > 解决方案 > 如何更改颤动材质按钮的字体大小?

问题描述

如何更改材质按钮的字体大小...有更好的方法吗?

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,
),

标签: buttonfluttertext-size

解决方案


Flutter 中的小部件架构使这变得非常简单: 的孩子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,
);

推荐阅读