The TextStyle class is used to define style for the text. The TextStyle constructor can take the following arguments :
FontWeight class can be used to specify the boldness of the font. You can use following contants :
w100, w200, w300, w400, w500, w600, w700, w800, w900, bold, normal
For example,
fontWeight : FontWeight.w500,
The constant bold
is same as w700
and normal
is same as w400
.
It specifies the background Paint of the Text widget. This is used when you want to draw some shape in the background, or paint something in the background. We will learn later how to paint drawing using Paint class.
This argument is used to specify the background color of the widget.
backgroundColor : Colors.red[400],
This argument is used to specify the font style of the text. The value is represented by FontStyle class. This class defines following two constant.
fontStyle : FontStyle.italic, fontStyle : FontStyle.normal,
The size of the text. The value should be either in double or integer which is in pixel.
fontSize : 18,
This specifies the line height of the text. The height of the line is equal to (fontSize * height)
pixel tall. The argument height
takes double or integer value.
If the fontSize
is 20
and height
is 2.0
, then the height of the line will be 2 * 2.0 = 4.0
pixel tall.
height : 2.0,
The amount of space to add between each letter. A negative value can be used to bring the letters closer. The value is in double and is in pixel.
letterSpacing : 5.0,
The amount of space (in logical pixel) to add between each word. A negative value can be used to bring the words closer.
wordSpacing : 10,
This represents the color of the text.
color : Colors.red[400],
It specifies the foreground Paint of the text. If color
is specified then forground
argument must be null
. We will learn Paint class later.
A liner decoration to draw near the text. TextDecoration class is used to specify the decoration. This class has defined the following constants :
lineThrough
: Draws a line through each line of the text.none
: Do not draws a decoration.overline
: Draw a line above each line of the text.underline
: Draw a line underneath each line of text.Here is an example,
decoration : TextDecoration.underline,
It specifies the color of the decoration which is applied on the text. For example to make the underline in red color, use this argument.
decorationColor : Colors.red[400],
This argument is used to specify the style of the decoration. The class TextDecorationStyle defines the various style. You can use one of the following constants:
dashed, dotted, double, solid, wavy,
For example,
decorationStyle : TextDecorationStyle.solid,
Decoration thickness is specifed using this argument. The default value is 1.0
decorationThickness : 2.85,
It specifies the name of the font to use when paining the text. If the font is defined in a package, this will be prefixed with packages/package_name
fontFamily : "Roboto",
This specifies a list of shadows that will be painted underneath the text. It supports multiple shadows. We will learn more about Shadow class to know how to make shadow.