提供者与InheritedWidget [英] Provider vs. InheritedWidget

查看:67
本文介绍了提供者与InheritedWidget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我错了吗,或者如果我们只是想在Widget树中传递一个值, Provider 只是具有dispose方法的InheritedWidget吗?

Am I wrong or if we just want to pass a value down the Widget tree, Provider is just an InheritedWidget with a dispose method?

推荐答案

是.提供程序确实主要是基于Inheritedwidgets的功能.

Yes. Provider is indeed mostly features based on Inheritedwidgets.

如果您想自己做,那就很好.但是您很快就会意识到,没有提供者,您将有数百条无用的重复行.

If you want to make your own, then that's fine. But you'll quickly realize that, without provider, you'll have hundreds of useless repetitive lines.

Provider基本上采用InheritedWidgets的逻辑,但将样板减小到严格的最低限度.

Provider basically takes the logic of InheritedWidgets, but reduce the boilerplate to the strict minimum.

这篇关于提供者与InheritedWidget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆