颤振冻结 + Bloc-如何两次发出相同的状态并重建 UI

发布于 2025-01-13 02:14:50 字数 187 浏览 5 评论 0原文

我有一个关于 Freezed+Bloc 包的问题

有谁知道如何两次发出相同的状态,但让 Bloc 知道他必须重建 UI

我无法

*我知道我可以使用 Equatable 实现这一目标,但我不太明白如何在使用 Freezed 时实现它

I have a question regarding Freezed+Bloc package

Does anyone know how to emit the same state twice but making Bloc knows he has to rebuild UI?

I'm not being able to

*I know I would be able to achieve this using Equatable, but I don't quite understand how to implement it while using Freezed

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

来世叙缘 2025-01-20 02:14:50

如果这仍然与任何人相关,那么这里是问题的解决方案。

@Freezed(equal: false)
class YourState with _$YourState {
  ...your state factories...
}

您需要在注释中指定 equal: false。
问题在于 Freezed 扩展了 Equitable,但如果状态相同,则 Bloc 不会改变状态。

If this is still relevant to anyone, here is the solution to the problem.

@Freezed(equal: false)
class YourState with _$YourState {
  ...your state factories...
}

You need to specify equal: false in the annotation.
The problem is that Freezed extends Equitable, but the Bloc does not change states if they are identical.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文