textElevation method
T
textElevation(})
为文本添加立体效果
参数:
- elevation: 立体效果的高度
- angle: 阴影的角度,默认为 0.0
- color: 阴影颜色,默认为半透明黑色
- opacityRatio: 不透明度比率,默认为 1.0
返回: 应用了立体效果的 TextSpan 对象
Implementation
T textElevation(
double elevation, {
double angle = 0.0,
Color color = const Color(0x33000000),
double opacityRatio = 1.0,
}) {
final double calculatedOpacity =
_elevationOpacityCurve(elevation) * opacityRatio;
final Shadow shadow = Shadow(
color: color.withOpacity(calculatedOpacity),
blurRadius: elevation,
offset: Offset(sin(angle) * elevation, cos(angle) * elevation),
);
return this.copyWith(
style: (style ?? const TextStyle()).copyWith(
shadows: [
shadow,
],
),
);
}