这段代码来自于预空安全版本的颤振。它使用VelocityX,我知道它有点便宜,但是我试图通过修改它来使它工作。
"radios": [
{
"id": 1,
"name": "92.7",
"tagline": "Suno Sunao, Life Banao!",
"color": "0xffa11431",
"desc": "The chills you get when you listen to music, is mostly caused by the brain releasing dopamine while anticipating the peak moment of a song.",
"url": "http://sc-bb.1.fm:8017/;",
"icon": "https://mytuner.global.ssl.fastly.net/media/tvos_radios/m8afyszryaqt.png",
"image": "https://mir-s3-cdn-cf.behance.net/project_modules/max_1200/b5df4c18876369.562d0d4bd94cf.jpg",
"lang": "Hindi",
"category": "pop",
"disliked": false,
"order": 1
},
...
]final rad = radios![index];
ZStack? Z = ZStack([
Positioned(
top: 0.0,
right: 0.0,
child: VxBox(
child: rad.category.text.uppercase.white.make().p16(),
).height(40).color(Colors.black).alignCenter.withRounded(value: 10.0).make(),
),
Align(
alignment: Alignment.bottomCenter,
child: VStack([
rad.name.text.xl3.white.bold.make(),
5.heightBox,
rad.tagline.text.sm.white.semiBold.make(),
],
crossAlignment: CrossAxisAlignment.center,
),
),
Align(
alignment: Alignment.center,
child: [const Icon(
CupertinoIcons.play_circle,
color: Colors.white,
),
10.heightBox,
"Double tap to play".text.gray300.make()
].vStack(),
),
]).clip(Clip.antiAlias);除了最后一行(即.clip(Clip.antiAlias) )之外,一切都很正常。
它给出了以下错误:错误
如果我删除.clip(Clip.antiAlias),它就能正常工作。
我以前解决了一个类似的错误
itemCount: radios?.length ?? 0,而且起作用了。
但是,ZStack Z1 = Z?.clip(Clip.antiAlias) ?? Z,其中Z没有.clip()方法,不起作用。甚至!空检查不起作用。
有什么解决办法吗?或者我错过了什么最佳实践?
发布于 2022-12-02 19:15:29
请加!空检查操作符在.clip()之前
您的问题的解决方案是->
ZStack Z1 = Z!.clip(Clip.antiAlias) ?? Z如果对象返回null,则Z必须是其他对象。
https://stackoverflow.com/questions/74660180
复制相似问题