how to change font size of flutter material button? how to change font size of flutter material button? flutter flutter

how to change font size of flutter material button?


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


You can make use of the style attribute of your Text widget.

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


just using the official docs TextStyle & fontSize

https://api.flutter.dev/flutter/painting/TextStyle-class.html

https://api.flutter.dev/flutter/painting/TextStyle/fontSize.html

fontSize default to 14 logical pixels, double

final double fontSize;

demo

import 'package:flutter/material.dart';void main() => runApp(App());class App extends StatelessWidget {  @override  Widget build(BuildContext context) {    return MaterialApp(      // home: StateApp(),      home: Scaffold(        appBar: AppBar(          title: Text("appbar"),          backgroundColor: Colors.blueAccent[700],        ),        body: Center(          child: StateApp(),        ),      ),    );  }}class StateApp extends StatefulWidget {  StateApp();  @override  createState() => _StateAppState();}class _StateAppState extends State<StateApp> {  int _counter = 0;  _updateCounter() => setState(() {    _counter++;  });  // _updateCounter() {  //   setState(() {  //     _counter++;  //   });  // }  @override  Widget build(BuildContext context) {    return Scaffold(      body: Center(        child: Column(          children: <Widget>[            Padding(              padding: const EdgeInsets.all(23.0),// double              child: Text(                'You have pushed the button this many times:',                style: TextStyle(                  fontWeight: FontWeight.bold,                  fontSize: 18.0,// double                ),              ),            ),            Center(              child: Text(                '$_counter',                style: TextStyle(                  fontWeight: FontWeight.bold,                  fontSize: 23.0,// double                ),              ),            ),          ],        ),      ),      floatingActionButton: FloatingActionButton(        onPressed: () {          // _counter++;          print("clicked = $_counter");          // setState(() {          //   _counter++;          // });          _updateCounter();        },        child: Icon(Icons.add),      ),    );  }}