简体   繁体   English

StateLess 小部件中的 Flutter ListView

[英]Flutter ListView in StateLess Widget

as I learned , in StateLessWidget we can't call any thing like setState to rebuild the widget tree and so on.据我StateLessWidget ,在StateLessWidget我们不能调用setState类的任何东西来重建小部件树等。

but when we scroll a listVeiw , the position and ... will change.但是当我们滚动listVeiw ,位置和 ... 会改变。 but as we in StatelessWidget , I don't know why it is possible to change the State of STL because the ListView has its own offset state and it can change and reflected in User Interface .但是就像我们在StatelessWidget ,我不知道为什么可以更改STL的状态,因为ListView有自己的偏移状态并且它可以更改并反映在 User Interface 中。

ListView is a stateful widget. ListView 是一个有状态的小部件。 Just because you wrap it in a stateless widget does not mean it also becomes stateless.仅仅因为您将它包装在无状态小部件中并不意味着它也变得无状态。

That's the whole magic, you can have many stateful and stateless widgets wrapped in stateful and stateless widgets...这就是整个魔术,您可以将许多有状态和无状态小部件包装在有状态和无状态小部件中......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM