- SingleChildScrollView не работает с несколькими компонентами в столбце — флаттер
- 2 ответа
- Flutter Problem: Listview Vs Column + SingleChildScrollView
- Let’s see how Listview works
- Now check how SingleChildScrollView + Column works
- scrollController of listView not working in singleChildScrollView #48105
- Comments
- chengweiou commented Jan 3, 2020
- What I want: get the scrolling position in order to make refresh and loadMore.
- iapicca commented Jan 3, 2020
- chengweiou commented Jan 4, 2020
- iapicca commented Jan 6, 2020 •
- chengweiou commented Jan 6, 2020
- iapicca commented Jan 7, 2020
- Flutter Problem: Listview Vs Column + SingleChildScrollView
- Let’s see how Listview works
- Now check how SingleChildScrollView + Column works
- Bottom Overflowed using SingleChildScrollView
- 2 Answers 2
SingleChildScrollView не работает с несколькими компонентами в столбце — флаттер
У меня проблема с трепетом. Мой экран не прокручивается. У меня есть несколько компонентов, использующих функцию столбца, расположенную один под другим, но простая функция прокрутки не работает.
Ниже код IncomeTransaction
Список просмотра не прокручивается. я пытаюсь использовать SingleChildScrollView, но все равно представление списка не прокручивается. Я читал в Интернете, что SingleChildScrollView не работает с атрибутом Column, но не уверен, правда ли это. Также я прочитал, что должен включить виджет в верхней части списка (общее количество невыполненных, общее количество полученных) как часть представления списка, но не знаю, как это сделать. этот заголовок не должен быть кликабельным.
Может ли кто-нибудь помочь мне изменить этот код, чтобы мой экран мог прокручиваться вверх или вниз. Кроме того, не уверен, почему я получаю ошибку переполнения дна, если я использую shrinkWrap: true, в построителе списка.
См. прикрепление изображения для вывода, который я получаю. список не прокручивается
2 ответа
В buildContent оберните ваш IncomeTransaction() в Expanded :
Как Expanded(child: IncomeTransaction()) .
Это должно исправить.
И вам не нужен SingleChildScrollView , если у вас уже есть ListView . ListView прокручивается сам по себе.
Размер IncomeTransaction в Column в методе buildContent() не ограничен, поэтому он занимает столько места, сколько необходимо для отображения всех элементов.
Вы должны обернуть его Expanded , чтобы оно заняло все место на экране.
Источник
Flutter Problem: Listview Vs Column + SingleChildScrollView
A lot of new flutter programmer while deciding the above topic will get confused, as they perform most of the things similar
Let’s take an example of a shopping app where we see a list of products from top to bottom
Let’s see how Listview works
Listview Widget shows the unlimited number of children inside it, but the main advantage of using ListView is it renders only visible items on the screen perhaps more specifically I would say ListView.Builder()
- It will be used when we have to render the same widget nth number of times.
- ListView, only the items that are visible are mounted and painted.
Note: One important point you should take care while choosing ListView
ListView() — Render all the items in the list, even if it is not visible.
`ListView.Builder()` — Render only visible items on the screen.
Now check how SingleChildScrollView + Column works
The column is used when we have to list widgets vertically on the screen and SingleChildScrollView widget provides scroll functionality for Column widgets.
When we used SingleChildScrollView+Column, the entire item list is rendered even if only a few items are visible.
So for complex layouts with a small number of items, the performance gain may not be worth the trouble, in which case we can use SingleChildScrollView.
- It will be useful when different widgets are needed with scroll functionality.
- For complex layouts, when items are less & performance, not a concern we can use it(Like when every other widget required some modification which is different from other)
- You could consider ListView as an optimization to the combination of SingleChildScrollView + Column.
- ListView is less flexible. So for complex layouts with a small number of items, the performance gain may not be worth the trouble, in which case we can use SingleChildScrollView.
Источник
scrollController of listView not working in singleChildScrollView #48105
Comments
chengweiou commented Jan 3, 2020
What I want: get the scrolling position in order to make refresh and loadMore.
scrollerController only work at 1, but I hope it can work at 2
the controller’s position is the only different.
scrollerController only doing the following printing.
there are many widgets between, so I put singleChildScrollView and ListView in different files.
Is this result is a issue or by design ? Will it fit or change in the future ?
The text was updated successfully, but these errors were encountered:
iapicca commented Jan 3, 2020
Hi @chengweiou
does this code represent the issue you are describing?
thank you
chengweiou commented Jan 4, 2020
Hi, @iapicca
Thats the printing that I want to see. but they still some different.
- It should not be 2 separated scroll.
- I put them in different files, I will check when we finish this one
this is the code shows the current problem. I copy from your code.
iapicca commented Jan 6, 2020 •
Hi @chengweiou
I’m not anymore sure about
what you are trying to achieve,
in your example the ScrollController of the ListView
is not «firing» simply because the listview isn’t scrolling;
since you do not wish to have 2 separate scrolling
you can also simplify the code as follow
does this solution answer your question?
thank you
chengweiou commented Jan 6, 2020
Hi @iapicca
sorry, your sample is not the code that I want.
I’m trying to use controller inside instead of outside because they are not in one file
i update my code and add more comment. Hope this can help
thank you
iapicca commented Jan 7, 2020
Hi @chengweiou
I apologize if my answer was confusing or inaccurate.
This platform is not meant for assistance on personal code,
but to improve or fix bug within flutter,
in your case the ScrollController is working as intended
and is not triggering simply because is not scrolling.
If you need assistance to implement your code
you may get some help if you post it on Stack Overflow.
Closing, as this isn’t an issue with Flutter itself,
if you disagree please write in the comments and I will reopen it
Thank you
Источник
Flutter Problem: Listview Vs Column + SingleChildScrollView
A lot of new flutter programmer while deciding the above topic will get confused, as they perform most of the things similar
Let’s take an example of a shopping app where we see a list of products from top to bottom
Let’s see how Listview works
Listview Widget shows the unlimited number of children inside it, but the main advantage of using ListView is it renders only visible items on the screen perhaps more specifically I would say ListView.Builder()
- It will be used when we have to render the same widget nth number of times.
- ListView, only the items that are visible are mounted and painted.
Note: One important point you should take care while choosing ListView
ListView() — Render all the items in the list, even if it is not visible.
`ListView.Builder()` — Render only visible items on the screen.
Now check how SingleChildScrollView + Column works
The column is used when we have to list widgets vertically on the screen and SingleChildScrollView widget provides scroll functionality for Column widgets.
When we used SingleChildScrollView+Column, the entire item list is rendered even if only a few items are visible.
So for complex layouts with a small number of items, the performance gain may not be worth the trouble, in which case we can use SingleChildScrollView.
- It will be useful when different widgets are needed with scroll functionality.
- For complex layouts, when items are less & performance, not a concern we can use it(Like when every other widget required some modification which is different from other)
- You could consider ListView as an optimization to the combination of SingleChildScrollView + Column.
- ListView is less flexible. So for complex layouts with a small number of items, the performance gain may not be worth the trouble, in which case we can use SingleChildScrollView.
Источник
Bottom Overflowed using SingleChildScrollView
I want to show an image on top below the top bar. The image is fixed.
Below the top bar I have any text field inside the SingleChildScrollView widget, but this not work when I try to scroll the elements.
The text field can’t rolling when I roll the screen to up or to down.
The stackoverflow want I type more text because I put many code, but my doubt is explained on text up.
2 Answers 2
To address the singleChildScrollView issue, you can wrap that in an Expandable widget and that will solve that problem. Though, you may want to look into using a SliverList for what you’re doing if you want the image to be up top and fixed in the app bar.
replace that with:
You are seeing that error because your SingleChildScrollView is inside a Column .
Another solution is to wrap your Parent Column with SingleChildScrollView instead of second one. But that will scroll your image too.
Or, if your image is a fixed one, you can add that to AppBar bottom :
Of course in this case if your snapshot.hasError or when connection is waiting, you will see this image(You can have a condition like isDataAvailable and make it true when connection state done and check it in bottom ).
Another way is wrap parent Column with another SingleChildScrollView but that will make two scroll views. So to avoid image (Outher scroll view) to not to scroll add scrollPysics: NeverScrollPhysics() (But I dont recommend unnecessary wrap with extra widget).
Источник