In this tutorial, I will try to discuss Flutter Text. If you do not know about Flutter Text, this tutorial is for you.
Text widget is used to display strings in the application. Text widgets have many attributes. Other than the String itself all other attributes are optional. Here is a list of useful attributes of the Text widget.
data= the string that will be shown using Text. It is the only compulsory attribute.
textStyle= set style of the text
textAlign= used to specify how the text is aligned.
overflow= set what happens when the String size exceeds the allocated size for the Text widget.
softWrap= determines whether the Text widget shows all content when there is not enough space available.
maxLine= set the maximum number of lines of the Text
Style parameter is one of them. We can style the text as per our needs using
TextStyle(). Text can hold a single style. TextStyle() holds multiple optional attributes such as font size, color, background color, font weight, letter spacing, word spacing, etc. Here is a list of useful attributes and what it does.
fontSize= Set the size of the text
Let's see the code for a better understanding:
Text( 'Hello World!', overflow: TextOverflow.ellipsis, maxLines: 3, softWrap: true, textAlign: TextAlign.justify, style: TextStyle( color: Colors.green, fontSize: 25, fontWeight: FontWeight.bold, letterSpacing: 2 ), ), ),
Hope this might help you in the development journey.
Read More: Want to know about Flutter Container?