Menu
CoddyTech

Font Size

Part of the Your First App section of Coddy's Flutter journey. Lesson 7 of 32.

A Text can take a style:, which says how the text looks. The style is a TextStyle, and its fontSize: sets how big the letters are:

Text(
  'Big news',
  style: TextStyle(fontSize: 40),
)

The words come first, then a comma, then style:. Without a style, text is 14 pixels high. A size of 40 is good for a headline, and 12 for small print.

challenge icon

Challenge

Easy

Make Big news bigger: give the text a style: with a fontSize: of 40.

Try it yourself

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: Text('Big news'),
        ),
      ),
    );
  }
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Your First App

Practice on your own: Online Flutter compiler