buttonfluttertext-size

how to change font size of flutter material button?


How do I change Font size of a material button... is there a better way to do this?

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

Solution

  • The widget architecture in Flutter makes this very simple: The child of the MaterialButton is a Text widget, which can be styled with its style property:

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