In Flutter, the Text
widget is used to display a short piece of text. It is a lightweight widget that does not have its own scrolling behavior, so it is often used in combination with other widgets, such as Container
or Expanded
, to control its layout and appearance.
Here is an example of how to use the Text
widget in Flutter:
Text( 'Hello World!', style: TextStyle( fontSize: 32, color: Colors.green, ), )
This will create a Text
widget that displays the text “Hello World!” with a font size of 32 and a green color.
The Text
widget has many additional properties and options that you can use to customize its appearance and behavior. For example, you can use the textAlign
property to align the text left, right, center, or justified. You can also use the maxLines
property to control the maximum number of lines that the text should occupy, and the overflow
property to specify how the text should be displayed if it overflows its bounds.
For more information about the Text
widget and its options, you can refer to the Flutter documentation.