列表不透明度问题颤动



我不知道如何实现不透明度,以免它影响其中的文本.....我只想让背景完全消失并留下文本。我不能把它留给白色,因为应用程序本身有背景

而且我也找不到有关如何在下面创建横跨屏幕的线以将磁贴彼此分开的文档

这是我的清单

? new ListView.builder(
itemCount: controlHeadings.length,
itemBuilder: (BuildContext context, int index) {
return new Opacity(
opacity: 0.9,
child: new Card(
color: Theme.CompanyColors.coolGrey,
elevation: 2.0,
child: new ListTile(
leading: new Text(
"${controlHeadings[index]['id']}",
style: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
title: new Text(
"${controlHeadings[index]['title']}",
style: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),

Opacity视为过滤器。它完全影响它的孩子。考虑到这一点,您的要求是"不可能的"。

相反,您应该提取需要绕过Opacity的内容,以确保它不是Opacity的子项。 您可以使用Stack来实现此目的:

Stack(
children: [
Positioned.fill(
child: Opacity(
opacity: .9,
child: Card(color: Colors.red),
),
),
Text("Not affected"),
],
)

或者,您可以使用withOpacity方法更改Card的背景颜色:

Card(
color: Colors.red.withOpacity(.9),
child: Text("foo"),
)

最新更新