FLUTTER:如何更改 gridview 内的背景颜色?

lmt*_*tvt 6 gridview colors flutter

我在 flutter 中使用 gridview ,遇到一个问题,屏幕的背景颜色是黑色的,但是当我返回 gridview 时,单元格的背景颜色是白色的。我想更改单元格的背景颜色。我尝试将 gridview 移动到容器内并添加 Boxdecoration,但它不起作用,你能帮助我吗?有我的代码:

Widget build(BuildContext context) {
return Scaffold(
  backgroundColor: Theme.of(context).backgroundColor,
  body: Center(
    child: Column(
      children: <Widget>[
        conseil(text, lien),
        SizedBox(height: 20,),
        Text("GAME PIN", style: TextStyle(fontSize: 40),),
        Container(
          padding: EdgeInsets.fromLTRB(30, 10, 30, 10),
            decoration: BoxDecoration(
              border: Border.all(width: 2.0, color: Color(0xffa8277b)),
              borderRadius: BorderRadius.circular(15),
            ),
            child: Text(id, style: TextStyle(fontSize: 30),)),
        Expanded(
          child: StreamBuilder<QuerySnapshot>(
            stream: Firestore.instance
                .collection('rooms')
                .document(id)
                .collection('users')
                .snapshots(),
            builder: (BuildContext context,
                AsyncSnapshot<QuerySnapshot> snapshot) {
              if (!snapshot.hasData)
                return Text("Chargement....");
              else {
                return GridView.count(
                    crossAxisCount: 6,
                    children: snapshot.data.documents
                        .map((DocumentSnapshot document) {
                      return OvalPic(
                          document['photo'], document['couleur']);
                    }).toList());
              }
            },
          ),
        ),
        button(mypink, 'COMMENCER', context),
        SizedBox(height: 15,)
      ],
    ),
  ),
);
Run Code Online (Sandbox Code Playgroud)

}

Arh*_*tvi 6

将它包裹在 a 中Container并添加color到它应该可以做到,

return Container(
color: Colors.black,
child: GridView.count(
                    crossAxisCount: 4,
                    children: snapshot.data.documents
                        .map((DocumentSnapshot document) {
                      return OvalPic(
                          document['photo'], document['couleur']);
                    }).toList()));
Run Code Online (Sandbox Code Playgroud)