我是flutter的新手,我想让代码尽可能少,所以我想调用它,但我不知道如何将shadow widget设置为固定变量
class ShadowTextStyle extends TextStyle {
final Color color;
final FontWeight fontWeight;
final double size;
final List<Shadow>? shadows;
const ShadowTextStyle({
required this.color,
required this.fontWeight,
this.size = 14,
this.shadows =//how to do it here,
,
}): super(
color: color,
fontWeight: fontWeight,
fontSize: size,
shadows: shadows,
);
}这是阴影参数,我想修复它
shadows: <Shadow>[
Shadow(
offset: Offset(1.0, 0.0),
blurRadius: 5.0,
color: Color.fromARGB(255, 0, 0, 0),
),
],发布于 2021-10-03 18:43:27
我不确定我的问题是否正确,但你可以将你的自定义阴影分配给一个变量,我总是有一个style.dart文件来保存我的自定义样式。
Shadow myShadow = Shadow(
offset: Offset(1.0, 0.0),
blurRadius: 5.0,
color: Color.fromARGB(255, 0, 0, 0),
);发布于 2021-10-04 07:07:16
我找到了。这就是我的意思:
const ShadowFile = <Shadow>[
Shadow(
offset: Offset(1.0, 0.0),
blurRadius: 5.0,
color: Color.fromARGB(255, 0, 0, 0),
)
];
class ShadowTextStyle extends TextStyle {
final Color color;
final FontWeight fontWeight;
final double size;
const ShadowTextStyle({
required this.color,
required this.fontWeight,
this.size = 14,
shadows: ShadowFile,
}) : super(
color: color,
fontWeight: fontWeight,
fontSize: size,
shadows: ShadowFile,
);
}https://stackoverflow.com/questions/69427749
复制相似问题