我做了一个应用程序,但是遇到了一个问题,我在ios和android上运行了该应用程序,但是一个屏幕却不是我想要的,SizedBox
中的所有孩子都没有完整显示(仅在IOS上),我认为这是IOS中Sizedbox
的问题,但我不知道如何解决。
我尝试使用其他小部件,但没有一个起作用。
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
body: StreamBuilder(
stream: Firestore.instance
.collection('rooms')
.document(pincode)
.snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
int result =
snapshot.data['Votes'][0] - snapshot.data['Votes'][1];
if (result <= 0)
perdantID = snapshot.data['Nominés'][1];
else
perdantID = snapshot.data['Nominés'][0];
leperdant = perdantID;
if (snapshot.data['nb screen'] == 2 && gotdata == 0) {
gotdata++;
gonext(context, perdantID);
}
return Center(
child: FutureBuilder(
future: Firestore.instance
.collection('rooms')
.document(pincode)
.collection('users')
.document(perdantID)
.get(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
var prenomperdant = snapshot.data['prénom'];
return Center(
child: Column(
children: <Widget>[
SizedBox(height: 30),
Text('$prenomperdant',
style: TextStyle(fontSize: 50)),
Padding(
padding: const EdgeInsets.fromLTRB(80, 0, 0, 0),
child: Text(' $subquestion',
style: TextStyle(fontSize: 35)),
),
StreamBuilder(
stream: Firestore.instance
.collection('rooms')
.document(pincode)
.collection('users')
.snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasData) {
return Column(
children: <Widget>[
SizedBox(
height: 140,
child: GridView.count(
crossAxisCount: 2,
children: snapshot.data.documents.map(
(DocumentSnapshot document) {
if (document['id'] == nomines[0] ||
document['id'] == nomines[1])
return Container(
child: OvalPic(
document['photo'],
document['couleur']),
);
else
return null;
}).toList()
..removeWhere((el) => el == null)),
),
SizedBox(
height: 190,
child: GridView.count(
crossAxisCount: 2,
children: <Widget>[
ListView.builder(
physics:
NeverScrollableScrollPhysics(),
itemCount: nbvotes[0],
reverse: true,
itemBuilder:
(BuildContext context,
int index) {
return Align(
alignment: Alignment.center,
heightFactor: 0.94,
child: Image(
image: AssetImage(
'assets/images/results/green.png'),
));
},
),
ListView.builder(
physics:
NeverScrollableScrollPhysics(),
itemCount: nbvotes[1],
reverse: true,
itemBuilder:
(BuildContext context,
int index) {
return Align(
alignment: Alignment.center,
heightFactor: 0.94,
child: Image(
image: AssetImage(
'assets/images/results/green.png'),
));
},
),
],
)),
],
);
} else
return CircularProgressIndicator();
},
),
(perdantID == nameid)
? Column(
children: <Widget>[
rbutton(mygreen, 'PASSER AU DEFI', context,
perdantID, ledefi),
SizedBox(height: 5),
Text('OU'),
SizedBox(height: 5),
rbutton(mypink, 'BOIRE', context, perdantID,
legage),
],
)
: SizedBox(height: 1)
],
));
} else
return Center(child: CircularProgressIndicator());
},
),
);
} else
return Center(child: CircularProgressIndicator());
},
));
}
}
答案 0 :(得分:0)
尝试使用
ConstrainedBox(
constraints: const BoxConstraints(minHeight: 140),
child:GridView....,
)
代替
SizedBox(
height: 190,
child: GridView...
)