firebase - FLUTTER:如何删除 gridview 单元格背景?
问题描述
我试图将 boxshadow 放在 gridview 内的容器中,但阴影位于单元格之外,并且单元格的背景颜色与页面背景颜色不同。我想让我的容器在 gridview 中具有相同的背景颜色和干净的 boxshadow 到我的容器。如果我在 gridview 之外使用它,它会完美运行。这是我的代码:
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
body: Center(
child: FutureBuilder(
future:
Firestore.instance.collection('rooms').document(pincode).get(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
nomines = snapshot.data['Nominés'];
thequestion = snapshot.data['Question'].toString();
return Column(children: <Widget>[
Text(thequestion),
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: Firestore.instance
.collection('rooms')
.document(pincode)
.collection('users')
.snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (!snapshot.hasData)
return Text("Chargement....");
else {
return new GridView.count(
crossAxisCount: 2,
children: snapshot.data.documents
.map((DocumentSnapshot document) {
if (document['id'] == nomines[0] ||
document['id'] == nomines[1])
return Container(
child: InkWell(
onTap: () {
vote(document['id']).then((a) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
Waitresults(),
));
});
},
child: Container(
decoration: BoxDecoration(
border: Border.all(
width: 2.0, color: Color(document['couleur'])),
boxShadow: <BoxShadow>[
BoxShadow(
color: Color(document['couleur']),
blurRadius: 0,
offset: Offset(7, 3))
],
shape: BoxShape.circle),
child: OvalPic(document['photo'],
document['couleur']),
),
),
);
else
return null;
}).toList()
..removeWhere((el) => el == null));
}
},
),
)
]);
} else
return CircularProgressIndicator();
},
),
),
);
}
解决方案
gridView
您可以用 a包裹container
,然后使用 中的属性color
来container
更改背景颜色。
Container(
color : Colors.black,
child : GridView.count(
.....
),
)
),
推荐阅读
- android - 在 kotlin 的画布视图中添加一个按钮
- javascript - 如何在不暴露密码的情况下从 Firebase 发送电子邮件?
- python - Pysaprk 将复杂的 json 解析为行
- database - 在 MongoDB 中启用访问控制不起作用
- javascript - 幻灯片/轮播在特定条件下无法正常工作?
- camera - 再立体化和透视投影之间有什么区别吗?
- excel - VBA代码更改PowerPoint中字体颜色选择器的颜色
- pyspark - 为什么 Pyspark 会抛出:“AnalysisException: `/path/to/adls/mounted/interim_data.delta` is not a Delta table”。即使文件存在......?
- javascript - 使用 reactjs 克隆 Youtube UI
- c# - C#:在自定义消息框中显示进度条变化