我试图将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();
},
),
),
);
}
答案 0 :(得分:1)
您可以用gridView
包裹container
,然后在color
中使用属性container
来更改背景颜色。
Container(
color : Colors.black,
child : GridView.count(
.....
),
)
),