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, ),
Flutter – Change Button Font Size Most of the buttons uses Text widget for displaying text in the button. You can change the font size of text in Text widget using style property. As a result, font size of Button text can be changed.
Raised buttons have a minimum size of 88.0 by 36.0 which can be overridden with ButtonTheme. So you can do it like the following: ButtonTheme( minWidth: 200.0, height: 100.0, child: RaisedButton( onPressed: () {}, child: Text("test"), ), );
Simply just wrap your Text widget to FittedBox widget like, Here I want to resize my AppBar text based on width. AppBar( centerTitle: true, title: FittedBox( fit: BoxFit. fitWidth, child: Text('Hey this is my long text appbar title') ), ), Text will be resized based on width of AppBar.
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, );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With