[英]Flutter - GridView not scrolling - bottom overflow
我有一個GridView
,其底部溢出如下。
我嘗試了很多方法,包括在我的 GridView 中添加ScrollPhysics()
,將我的 GridView 包裝在 Expanded 小部件中,或者將我的 Container 包裝在 Expanded 小部件中。 以上都不起作用。 有人可以請教嗎?
下面是我的代碼:
Widget portfolioRow = StreamBuilder(
stream: Firestore.instance.collection('portfolio').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return Text("Loading...");
return GridView.builder(
physics: ScrollPhysics(),
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 70.0,
mainAxisSpacing: 70.0,
),
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
portfolioContainer(context, snapshot.data.documents[index]));
},
);
Widget portfolioContainer(
BuildContext context, DocumentSnapshot documentSnapshot) {
return Container(
height: 500,
width: 302,
decoration: myPortfolioDecoration(),
child: Column(children: [
Container(
margin: const EdgeInsets.only(top: 20, bottom: 10),
width: 250,
height: 250,
decoration: myPortfolioDecoration(),
),
Container(
height: 3,
width: 30,
margin: const EdgeInsets.only(top: 15, bottom: 20, right: 210),
decoration: BoxDecoration(color: Colors.yellow)),
Container(
padding: const EdgeInsets.only(bottom: 10, left: 30),
alignment: Alignment.centerLeft,
child: Text.rich(
TextSpan(
text: documentSnapshot.data["title"],
style: Theme.of(context).textTheme.headline5),
),
),
Container(
padding: const EdgeInsets.only(left: 30, bottom: 20),
alignment: Alignment.centerLeft,
child: Text.rich(
TextSpan(
text: documentSnapshot.data["tagline"],
style: Theme.of(context).textTheme.bodyText1),
),
),
]),
);
}
我通過添加childAspectRatio
成功擺脫了底部溢出:
childAspectRatio: MediaQuery.of(context).size.height / 1100,```
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.