Flutter – How to change Font Size of Text Widget?

In flutter app development, Text widget is the most usable widget even though we can say other widgets also use Text widgets for displaying information. In flutter by default font size is 14 pixels. We are going to share with you In this article How to change Font Size of Text Widget.

 

Default font size : 

In beginning, we saw flutter provide a default font size is 14 pixels. You can see the below example.

Text("Errorgram")

You can see the below screenshot with the default font size.

 

 

How to change the default font size in Text:

We can easily change the default font size in the text widget using style properties of the Text widget like the below example.

Text(
            "Errorgram",
            style: TextStyle(fontSize: 20),
          )

Full example :

class Errorgram extends StatefulWidget {
  const Errorgram({Key? key}) : super(key: key);

  @override
  State<Errorgram> createState() => _ErrorgramState();
}

class _ErrorgramState extends State<Errorgram> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
        bottom: false,
        child: Scaffold(
          appBar: AppBar(
            title: Text("Errorgram"),
          ),
          body: Center(
              child: Text(
            "Errorgram",
            style: TextStyle(fontSize: 20),
          )),
        ));
  }
}

 

Conclusion:

In this post, We saw How to change the font size of text widgets easily in a flutter. I hope this article will help you.

Tags: