如何在Flutter中的ListView.Builder中的索引处设置小部件的状态 [英] How to set the state of a widget at an index in a listview.builder in flutter
问题描述
我在流构建器中有此listview.builder.在列表视图中,每个索引的容器中都有一个按钮和循环进度指示器,现在我只想在按下按钮时才在该特定索引处显示循环指示器.
我尝试使用布尔值来隐藏和显示指标.但是我的问题是,当每次尝试使指示器可见时,所有这些指示器都变得可见,这不是我想要的.我该如何实现?
您应该将每个列表项构建为具有自己的逻辑和状态的独立小部件,这样,您可以为每个项目使用不同的布尔状态属性.>
I have this listview.builder in a stream builder. Inside the listview I have a button and circular progress indicator in a container at every index, now I want to show the circular indicator at that particular index only when the button is pressed.
I have tried to use a boolean to hide and show the indicator. however my problem is when every try to make the indicator visible all of them become visible which is not what I want. how can I achieve this?
You should build every list item as a separate widget with its own logic and state, this way you can have a different boolean state property for every item.
这篇关于如何在Flutter中的ListView.Builder中的索引处设置小部件的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!