How do you change the font size on a TextButton flutter

1,238

Please try out

TextButton(
            style: ButtonStyle(
              foregroundColor: MaterialStateProperty.all<Color>(
                  Colors.white.withOpacity(0.7)),
              overlayColor: MaterialStateProperty.resolveWith<Color>(
                  (Set<MaterialState> states) {
                if (states.contains(MaterialState.focused) ||
                    states.contains(MaterialState.pressed))
                  return Colors.red.withOpacity(0.7);
                return Colors.red; // Defer to the widget's default.
              return Colors.white70;
              }),
            ),
            child: new Text('Hello World', style: TextStyle( fontSize: 30),),
          )
Share:
1,238
ukholly
Author by

ukholly

Updated on December 30, 2022

Comments

  • ukholly
    ukholly over 1 year

    here would you change the font size of Hello World in this example? Tried the font style etc but gets errors, what am I missing pls?

    new TextButton(
          style: ButtonStyle(
            foregroundColor: MaterialStateProperty.all<Color>(Colors.white.withOpacity(0.7)),
            overlayColor: MaterialStateProperty.resolveWith<Color>(
                    (Set<MaterialState> states) {
                  if (states.contains(MaterialState.focused) ||
                        states.contains(MaterialState.pressed))
                      return Colors.red.withOpacity(0.7);
                    return Colors.red;
                  return Colors.white70; // Defer to the widget's default.
                }
            ),
          ),
          child: new Text('Hello World'),
    
    • Naveen Avidi
      Naveen Avidi almost 3 years
      "fontSize" in Text() widget using Text(style: TextStyle(fontSize: 25))
  • ukholly
    ukholly almost 3 years
    Thanks all! So simple when you know how!