How To Easily Change Flutter Text Font Size

flutter text font size

In this easy Flutter post, you’ll see a simple Flutter example for changing Flutter text font size in Flutter apps. We’ll discuss each and everything about Flutter text font size so that you’ll be able to easily customize Flutter text font size in your own Flutter code as well. Let’s not hold off more and begin customizing Flutter text font size.

What is Flutter Text Font Size?

Flutter text font size as the name suggests, it is the size of text in Flutter text widget. First we will see what the default Flutter text font size looks like and then we will practically change the font size of Flutter text. So let’s get started with an easy Flutter example.

Default Flutter Text Font Size

In order to see what the default font size of Flutter text is, we have to define a simple Flutter text widget with some text. See the below code:

Text(
      'This is the default Flutter text font size'
        )
flutter text default font size
You can see the default Flutter text font size in the image given above. Let’s now see how to change the size of the text.

Change Flutter Text Font Size

To change the Flutter text font size, we have to use the style constructor of the Flutter text widget class and pass text style class to it. Then by using the font size constructor of the text style class, we can easily change the font size of text in Flutter text widget. This font size constructor takes a double(decimal) value but we can also pass integer to it(it will automatically convert it). For demonstration, we have passed 23 to it. See the below code:

Text(
       'This is the custom Flutter text fontsize',
       style: TextStyle(fontSize: 23),
        )
flutter text font size
The font size of the text is now changed and it looks bigger. So we have successfully changed the Flutter text font size.
In this way, you can easily change Flutter text font size in your own Flutter apps as well. If you still have any questions regarding the customization of Flutter text font size then let me know in the comments. I would love to answer them.
The complete Flutter source code for the above customized Flutter text font size is given below.

Flutter Text Font Size Implementation Source Code

flutter text font size

import 'package:flutter/material.dart';
void main() {
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Homepage(),
    );
  }
}
class Homepage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
            body: Center(
      child: Padding(
        padding: const EdgeInsets.all(15),
        child: Text(
          'This is the custom Flutter text fontsize',
          style: TextStyle(fontSize: 23),
        ),
      ),
    )));
  }
}

Conclusion

As conclusion, we now know how to practically implement and change Flutter text font size in Flutter text widget. I would be looking forward to hear what you think about this article in the comments.  I also have prepared other informative articles on Flutter widgets, amazing Flutter templates with free source code, Flutter app development, Flutter animations, and more. Thank you for reading this post.

Leave a Comment

Your email address will not be published.