notifyListeners()实际上是如何工作的?

发布于 2025-01-12 18:20:58 字数 327 浏览 5 评论 0原文

因此,我有这个类,并使用方法 addItem 将一些项目添加到我的购物车和 itemsCount 以使我的总项目显示在 AppBar 的购物车图标中。

我的问题是,如果 itemsCount 没有,那么在我使用 addItem 后 itemsCount 如何更新 通知监听器()?

addItem 中的notifyListeners() 会更新它吗? notifyListeners() 实际上更新了所有应用程序中正在使用的类中的所有方法?

代码图片

So, I have this class and I use the method addItem to add some item to my cart and itemsCount to have my total items show up in my cart icon in AppBar.

My question is, how the itemsCount is update after I use addItem if itemsCount does not have
notifyListeners( )?

The notifyListeners( ) in addItem that update that? The notifyListeners( ) actually update all the methods in class that are being using in all the app?

code image

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文