A Text widget displays text within an application. Text widgets are created by calling their constructor Text(), and passing in some arguments. The most basic form is:

Text('Hello, world!')

The information in quotes tells the widget what text to display.

We can also customize the text further.

The Text widget constructor allows additional named parameters, including the following:

  • style: Specify the text style, for example Colors.red and a size of 72 pixels
  • textAlign: Specify the text alignment to left, center or right.
  • textDirection: Specify left to right text direction or the reverse.
  • softWrap: Specify if the text should wrap to another line if it runs out of room.

To place the Text widget into our app, we will set it to be the body widget of our Scaffold widget. Here’s what that will look like:

Scaffold(body: Text('Hello!'))

Let’s try it out.


Create a Text widget with any text as the body attribute of our Scaffold.

Press the Run button to run the application. Try changing the text as well!

The text will appear as pretty small, we will fix that in the next exercise.


Create a body attribute within Scaffold:


Then create a Text widget:

Text('The text I want to display goes here')

Use that text widget as the body of the Scaffold.


The inside of main should look like:

runApp( const MaterialApp( home: Scaffold( body: Text('Codecademy: Flutter Edition') ) ) );

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?