目錄:
- 文本樣式的參數(shù)
- 默認文本樣式
- 文字加波浪線
- 文字加橫線
- 文字加陰影
- 文字加背景框
- 文字加漸變色
- 文字風格屬性
- 文字加雙下劃線
一、文本樣式的參數(shù)
下面列出了 TextStyle widget 的全部參數(shù):
bool? inherit,
Color? color,
Color? backgroundColor,
String? fontFamily,
List<String>? fontFamilyFallback,
double? fontSize,
FontWeight? fontWeight,
FontStyle? fontStyle,
double? letterSpacing,
double? wordSpacing,
TextBaseline? textBaseline,
double? height,
Locale? locale,
Paint? foreground,
Paint? background,
List<ui.Shadow>? shadows,
List<ui.FontFeature>? fontFeatures,
TextDecoration? decoration,
Color? decorationColor,
TextDecorationStyle? decorationStyle,
double? decorationThickness,
String? debugLabel
二媒熊、默認文本樣式
return Material(
child: Center(
child: Text(
'好好學習,努力賺錢',
//style: textStyle,
),
),
);
三坟比、文字加波浪線
return const Material(
child: Center(
child: Text(
'好好學習芦鳍,努力掙錢',
style: TextStyle(
fontSize: 20,
decoration: TextDecoration.lineThrough,
decorationStyle: TextDecorationStyle.wavy,
),
),
),
);
四、字體加橫線
return const Material(
child: Center(
child: Text(
'好好學習葛账,努力掙錢',
style: TextStyle(
fontSize: 20,
decoration: TextDecoration.lineThrough,
decorationThickness: 4,
),
),
),
);
五柠衅、文字加陰影
return const Material(
child: Center(
child: Text(
'好好學習,努力掙錢',
style: TextStyle(
fontSize: 36,
shadows: [
Shadow(
color: Colors.blue,
blurRadius: 1,
offset: Offset(1, 1),
),
Shadow(
color: Colors.red,
blurRadius: 10,
offset: Offset(-5, 5),
),
],
),
),
),
);
六籍琳、文字加背景框
return Material(
child: Center(
child: Text('好好學習菲宴,努力掙錢',
style: TextStyle(
background: Paint()
..strokeWidth = 30.0
..color = Colors.blue
..style = PaintingStyle.stroke
..strokeJoin = StrokeJoin.round)),
),
);
七、文字加漸變顏色
return Material(
child: Center(
child: Text(
'好好學習趋急,努力掙錢',
style: TextStyle(
fontSize: 36,
fontWeight: FontWeight.bold,
foreground: Paint()
..shader = linearGradient),
),
));
八喝峦、文字風格的屬性:字體大小、顏色呜达、高度谣蠢、詞間距、字母間距查近、字體加粗眉踱、字體。
return const Material(
child: Center(
child: Text(
'好好學習霜威,努力掙錢',
style: TextStyle(fontSize: 32,color: Colors.black38,height: 6,wordSpacing: 12,letterSpacing: 2,fontWeight: FontWeight.bold,fontStyle: FontStyle.italic),
),
));
九谈喳、文字加雙下劃線
return const Center(
child: Text(
'好好學習,努力掙錢',
style: TextStyle(fontSize: 32),
),
);