如何更改颤振材料按钮的字体大小?

Iri*_*ngo 19 button text-size flutter

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

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,
),
Run Code Online (Sandbox Code Playgroud)

bof*_*mer 32

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,
);
Run Code Online (Sandbox Code Playgroud)

  • 你在我的解决方案中添加了什么? (3认同)

cre*_*not 6

您可以使用窗口小部件style属性Text

MaterialButton(
  ...
  child: Text(
    'material button',
    style: TextStyle(
      fontSize: 20.0, // insert your font size here
    ),
  ),
)
Run Code Online (Sandbox Code Playgroud)