Text. The way of creating a page is the same as before, you do not care about this, you just focus on the
Textwidget now. We will put them all in the
childrento continue our tutorial.
this.datais where we put the
String, this is easy to understand, we do not talk about this. the
styleis most common to use.
this.localecontrol its language,this time I don't plan to talk about it, I will write another article to explain it. So let's talk about the parameters one by one.
TextStyleclass, look at its definition,so many important parameters are here,such as the
colorparameter control the color of
fontSizecontrols its font size. We just show an example for simple param.
backgroundt,the background is a Paint that controls the color or other things, I don't want to expand this for more detail.
foregroundis also as the
backgroundabove, so just use the
..is a special operator in the flutter.
Textwith the foreground, be careful that we can't use the color parameter with this, so you can only choose one parameter.
FontWeight, you can use its constant with a fore definition. We will use the
FontWeight.w700, it represents bold text. The other constants you can find in the class
FontWeight,remain to you.
FontStyle, we use its only two constants.As follows, this example will show an italic text.
Helloif set this param, the distance between
H,e,l,l,owill depend on this param.
shadows, we can see this.
Shadowconstructor is below.
offsetis the direction from the origin point of the widget, the
blurRadiusis the distance of the blurred space.
decoration, decorationColor, decorationStyle. They draw the same line show in the Text, the
decorationcontrols the location,
decorationColorcontrol the color,
decorationStylecontrol the shape. The definition is below.
assets/font. You should know the folders are created by myself, you can do that too.
pubspec.yamlfile in our project,as I note with the red rectangle and paste the config as well.
maniguas we set above.
Textlocation in the parent widget, I will show you it in a
TextAlignconstants are below, I just use the
Textfrom left from right, but we can change it with the
maxLinesto limit the space, in above part we can see the Text show two lines when there is no space in the horizontal direction.
Textlarger or more little, we can use the
fontSizeto change its size. But there is another choice to change its scale, the
textScaleFactor. It depends on the
fontSize, for example, when we set
fontSize=10 ,textScaleFactor =2, the real scale of the
Textwill be equal to 20, means that the real-scale=