Почему я не могу прокручивать listView? Я получаю ошибку typi c `A RenderFlex переполнен на xx пикселей внизу` - PullRequest
0 голосов
/ 30 мая 2020

Я новичок в трепетании и пытаюсь избежать проблемы с прокруткой внизу. Я хотел использовать ListView для прокрутки ряда элементов. У меня вопрос, почему у меня проблема A RenderFlex overflowed by 94 pixels on the bottom.? элемент, который превышает эти пиксели, - это мой ListView, но у этого элемента должна быть собственная прокрутка внутри.

это мой код:

    Widget build(BuildContext context) {
      return GestureDetector(
        onTap: () {
          //here
          FocusScope.of(context).unfocus();
          new TextEditingController().clear();
        },
        child: Scaffold(
          backgroundColor: Colors.black,
          body: SafeArea(
              child: Stack(children: <Widget>[
            Align(
                alignment: Alignment.bottomCenter,
                child: SingleChildScrollView(
                  child: Container(
                    padding: EdgeInsets.only(top: 40),
                    color: Colors.white,
                    width: MediaQuery.of(context).size.width,
                    height: MediaQuery.of(context).size.height * 0.78,
                    child: Column(
                      children: <Widget>[
                        Row(
                          children: <Widget>[
                            Container(),
                            Expanded(
                                child: Container(
                              child: Container(),
                            ))
                          ],
                        ),
                        SizedBox(height: 20),
                        Row(
                          children: <Widget>[Container()],
                        ),
                        SizedBox(height: 20),
                        Container(
                            child: Column(
                          children: <Widget>[
                            Row(
                              children: <Widget>[
                                SizedBox(width: 10),
                              ],
                            ),
                            SizedBox(height: 10),
                            Row(
                              children: <Widget>[(Container())],
                            ),
                            SizedBox(height: 10),
                          ],
                        )),
                        Divider(
                          height: 50.0,
                          color: Colors.red,
                        ),

                        SizedBox(height: 35), //SingleChildScrollView
                        Container(
                          child: ListView(shrinkWrap: true, children: <Widget>[
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                            Text("LOREM "),
                          ]),
                        )
                      ],
                    ),
                  ),
                )),
          ])),
        ),
      );
    }

enter image description here

Ответы [ 2 ]

1 голос
/ 30 мая 2020

мой друг, когда вы хотите использовать listview, вы должны определить высоту для списка, потому что listview принимает неограниченную высоту

Пример:

Container(
height: 50,
child: ListView(shrinkWrap: true, children: <Widget>[
Text("LOREM "),
Text("LOREM "),
Text("LOREM "),
Text("LOREM "),
]),)
0 голосов
/ 30 мая 2020

Оберните свой список в расширенный или любой другой такой гибкий виджет (гибкий).

...