Flutter - GridView не прокручивается - нижнее переполнение - PullRequest
0 голосов
/ 19 июня 2020

У меня GridView с его нижним переполнением, как показано ниже.

enter image description here

Я пробовал много способов, в том числе добавление ScrollPhysics() в моем GridView, заключив мой GridView в расширенный виджет, или заключив мой Контейнер в расширенный виджет. Ничего из вышеперечисленного не работает. Может кто-нибудь посоветовать, пожалуйста?

Ниже мой код:

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),
        ),
      ),
    ]),
  );
}

1 Ответ

0 голосов
/ 25 июня 2020

Мне удалось избавиться от нижнего переполнения, добавив childAspectRatio:

childAspectRatio: MediaQuery.of(context).size.height / 1100,```
...