为什么大多数代码都使用提供商软件包,并且不使用getx/riverpod/bloc?

发布于 2025-02-13 03:03:45 字数 1453 浏览 1 评论 0原文

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

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

发布评论

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

评论(1

分分钟 2025-02-20 03:03:45

提供商 包装有很多优势,特别是与changeNotifiers结合使用 -

非常容易理解和理由。该文档清晰明确,也为最佳实践提供指南。
您可以在小部件中同时使用反应性和非反应性变频器,这意味着您可以依靠其他changeNotifier,而无需通知更改。这提供了许多性能优势。
您也可以将提供商用作简单的依赖注入容器。唯一的事情是,您需要可以访问附加的小部件树的buildContext。


getx 不仅是状态管理库,而且是一个小框架,结合了路由管理和依赖项注入。它旨在在额外的轻量级但有力的扑朔迷离解决方案中提供顶级的开发体验。 GETX具有构建的三个基本原则:

性能:专注于最低记忆和资源

生产率的消耗:直观有效的工具与简单和直接的语法结合在一起,最终节省了开发时间

组织:将业务逻辑从视图和演示逻辑中脱成逻辑无法获得。比这更好。您不需要上下文即可在路线之间导航,也不需要状态的小部件


There are many advantages of the Provider package specially when combined with ChangeNotifiers-

Its very easy to understand and reason about. The documentation is clear and concise and provides guidelines to best practices as well.
You can use both reactive and non-reactive ChangeNotifiers in a Widget which means that you can depend on other ChangeNotifiers without being notified about changes. This provides many performance benefits.
You can use Provider as a simple dependency injection container as well. The only thing is, you need to have access to the BuildContext attached the widget tree.


GetX is not only a state management library, but instead, it is a microframework combined with route management and dependency injection. It aims to deliver top-of-the-line development experience in an extra lightweight but powerful solution for Flutter. GetX has three basic principles on which it is built:

Performance: focused on minimum consumption of memory and resources

Productivity: intuitive and efficient tool combined with simplicity and straightforward syntax that ultimately saves development time

Organization: decoupling business logic from view and presentation logic cannot get better than this. You do not need context to navigate between routes, nor do you need stateful widgets

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