mFe*_*ein 2 flutter flutter-layout
我试图了解如何ShaderMask工作。如果我按照此处ShaderMask文档中的示例进行操作:
ShaderMask(
shaderCallback: (Rect bounds) {
return RadialGradient(
center: Alignment.topLeft,
radius: 1.0,
colors: <Color>[Colors.yellow, Colors.deepOrange.shade900],
tileMode: TileMode.mirror,
).createShader(bounds);
},
child: const Text('I’m burning the memories'),
)
Run Code Online (Sandbox Code Playgroud)
我明白了:
(下面的双线Text显然表示缺少 a Theme)
然后,如果我将其包围ShaderMask在 a 中,Scaffold我会得到:
Scaffold(
body: Center(
child: ShaderMask(
shaderCallback: (Rect bounds) {
return RadialGradient(
center: Alignment.topLeft,
radius: 1.0,
colors: <Color>[Colors.yellow, Colors.deepOrange.shade900],
tileMode: TileMode.mirror,
).createShader(bounds);
},
child: const Text('I’m burning the memories'),
),
),
);
Run Code Online (Sandbox Code Playgroud)
一切都过去了!在ShaderMask似乎已经恰恰忽略了,而且也没有提到对文档有关此问题的,为何Scaffold“”禁用“的”ShaderMask?
你失踪了 -blendMode财产
有关 - blendMode 属性的更多信息
工作代码:
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ShaderMask(
blendMode: BlendMode.srcATop, // Add this
shaderCallback: (Rect bounds) {
return RadialGradient(
center: Alignment.topLeft,
radius: 1.0,
colors: <Color>[Colors.yellow, Colors.deepOrange.shade900],
tileMode: TileMode.mirror,
).createShader(bounds);
},
child: const Text('I’m burning the memories'),
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2054 次 |
| 最近记录: |