0
0
FlutterConceptBeginner · 3 min read

What is Text Widget in Flutter: Simple Explanation and Example

The Text widget in Flutter is used to display a string of text on the screen. It is a basic building block for showing readable content in your app's user interface.
⚙️

How It Works

The Text widget in Flutter works like a label or sign in real life that shows words or sentences. When you add a Text widget to your app, Flutter draws the text on the screen where you place it.

Think of it as putting a sticky note on a wall to show a message. You can change the size, color, and style of the text to make it look just right. Flutter handles all the details of drawing the letters clearly and nicely on different screen sizes.

💻

Example

This example shows how to use the Text widget to display a simple greeting message in the center of the screen.

dart
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('Hello, Flutter!'),
        ),
      ),
    );
  }
}
Output
A white screen with the text 'Hello, Flutter!' centered in black font.
🎯

When to Use

Use the Text widget whenever you want to show words or sentences in your app. It is perfect for titles, labels, instructions, or any readable content.

For example, you might use Text to show a welcome message on the home screen, display a button label, or show error messages to users. It is one of the most common widgets because almost every app needs to show text.

Key Points

  • Text widget displays a string of text on the screen.
  • You can customize font size, color, weight, and style.
  • It is used for any readable content in the app UI.
  • Works well inside layout widgets like Center, Row, and Column.

Key Takeaways

The Text widget shows readable text in your Flutter app UI.
You can easily style the text with font size, color, and weight.
Use Text for labels, messages, titles, and any on-screen words.
Text works inside layout widgets to position it on the screen.