我在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,)
],
),
),
);
}
答案 0 :(得分:2)
将其包装在PersistentEntity
中并添加Container
即可,
color
答案 1 :(得分:0)
我能够使用高程属性删除Grid Tile背景色。我尝试如下,
template<typename ErrorType>
void throwError(const std::string &file,
const std::string &function,
unsigned int line,
const std::string &msg = "")
{
std::ostringstream errMsg;
errMsg << file << ":" << line << ":" << function << ":"
<< "\nError: " << msg << std::endl;
std::cerr << errMsg.str();
throw ErrorType(errMsg.str());
}
共享它,因为以后可能会有用。