Introduction
The Text widget shows words on the screen. Styling makes the words look nice and clear.
The Text widget shows words on the screen. Styling makes the words look nice and clear.
Text( 'Your text here', style: TextStyle( color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold, fontStyle: FontStyle.italic, decoration: TextDecoration.underline, ), textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis, )
The Text widget shows text on screen.
The style property lets you change color, size, weight, and more.
Text('Hello World')Text('Hello Flutter', style: TextStyle(color: Colors.blue, fontSize: 20))
Text('Bold and Italic', style: TextStyle(fontWeight: FontWeight.bold, fontStyle: FontStyle.italic))Text('Underlined Text', style: TextStyle(decoration: TextDecoration.underline))This app shows a centered text with purple color, medium bold, italic style, and an overline decoration.
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( home: Scaffold( appBar: AppBar(title: const Text('Text Widget Example')), body: const Center( child: Text( 'Welcome to Flutter!', style: TextStyle( color: Colors.deepPurple, fontSize: 24, fontWeight: FontWeight.w600, fontStyle: FontStyle.italic, decoration: TextDecoration.overline, ), textAlign: TextAlign.center, ), ), ), ); } }
Use TextAlign to control text alignment inside its container.
Use maxLines and overflow to handle long text gracefully.
Colors come from the Colors class for easy use.
The Text widget displays words on the screen.
Styling is done with TextStyle to change color, size, weight, and decoration.
Text alignment and overflow help control how text fits in the space.
Text widget do in Flutter?Text widget?Text( 'Hello Flutter', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), textAlign: TextAlign.center, )
Text( 'Welcome', style: TextStyle(fontSize: '20'), )
Text widget code correctly achieves this?Pass the test and this pattern moves unknown