问题标签 [flutter-listview]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
flutter - Flutter Animated List: Conditionally add ListView item
I am have an animated list in my flutter project.
For every element in that list I have a grid of buttons that are placed dynamically from a Firestore stream. Sometimes that will come back with 10 items in the grid but other times that will comeback with 0 items.
When a button on the grid in a list element is pushed it will search firestore and create a new grid of buttons in the next list element below.
The problem that I have is when it comes back with 0 grid buttons I don't want it to create a new list element (an empty list element with no grid buttons). I tried returning a container with 0 size as a work around but animated list still gives it some height so you can see there is a problem. I also understand that this would be bad practice as you have non visible empty list elements in the list.
I start with a list of foods as strings:
I then have an animated list:
I set the AnimatedList size to the length of the foods list.
I set the child of the Animated List to a class that searches firebase and returns a card with the grid of buttons on it like this:
then in the on pressed method for each grid button I add a new list element like this:
The problem is a chicken or the egg problem I will try to show below:
- List item is generated from the index 0 in the food list and all stream data is if from food list index 0 firebase results.
- On pressed for a grid item in the first list row is pressed to add a new list row with a new set of grid items. This will then update the food list array and the call for the list to add new row of grid buttons. The issue is because this is in the onpressed for the first rows grid there is no knowledge of what will be returned for the next row so there is no way of knowing if it will return a grid of size 0 in the next list row in the current way it is setup.
I have tried returning null, container of 0 width and height but have had no luck. I am not sure what I can do to fix it.
Thanks for your help
flutter - 在flutter中单击卡片项目时如何动态创建Listview?
我有一个列表视图中显示的类别列表。现在我试图在单击每个类别列表时创建子类别并将其显示到颤动的另一个列表视图中。
对于每个类别,我必须动态创建另一个子类别列表。我有 json 数据和良好的工作类别列表。我必须根据类别列表创建子类别。
我有一个模型类,其中还包含类别详细信息和子类别详细信息。
我怎么能做到这一点?
模型类
json响应:
flutter-listview - 如何在屏幕底部自动显示列表中的展开项目?
我想制作一个扩展项目列表,当项目展开时,所有这个项目视图都可以显示,我尝试在 onExpansionChanged 中做一些事情,比如:
但它不起作用。
我可以按位置分配项目以滚动吗?
flutter - Flutter如何创建列表视图自动滚动?
我正在尝试制作一个自动滚动到最新数据点的 ListView。我厌倦了通过创建一个使用 .jumpTo 方法的 _scrollToBottom 函数来做到这一点。
'child.parentData != null': is not true.
但我在应用程序和调试控制台中得到一个空白屏幕
。
关于如何实现自动滚动的任何建议?
这是我当前代码的相关部分:
listview - 如何添加一个位于页面底部并可以使用 ListView 滚动的小部件?
我有一个构建多张卡片的 ListView,在它们下面,我想添加一个 Text 小部件,它位于 ListView 下方但位于页面底部,这意味着您必须向下滚动到最后一张卡片才能看到它.
我目前在 ListView 下有 Text,但 Text 在页面上是静态的,不能使用 ListView 滚动。
flutter - 为什么所有 Slider 小部件在 ListView.builder 中一起移动?
我有一个 ListView.builder() 方法,可以构建多张卡片,其中包含一张图片、一些文本和每张卡片的滑块。问题是,每当我移动滑块时,它们都会一起移动,值也是如此。
我该怎么做才能使每个滑块和值单独移动/增加?
flutter - 使用 ListView 时出现错误使用 ParentDataWidget 错误
在我的应用程序的这一部分中ListView
,当我运行应用程序时出现此错误,我无法解决:
错误:
flutter - 当状态代码在单独的文件中定义时,Listview 未显示
我是 Flutter 开发的新手,这可能是一个幼稚的问题,但我正在关注 Flutter 开发网站上的初学者教程,但我的列表视图没有显示。我更改了一些类/函数名称,并将代码放在不同的文件中,但不确定这里出了什么问题,这应该是一个无限的随机单词列表。
这是完整的代码:
和
我也不明白这是什么final index = pos ~/ 2;
逻辑。官方文档说:
表达式 i ~/ 2 将 i 除以 2 并返回一个整数结果。例如:1, 2, 3, 4, 5 变为 0, 1, 1, 2, 2。这会计算 ListView 中的实际单词对数,减去分隔小部件。
但我猜我用错了。