[英]How to call method in specific widget by provider
Simple question for provider. 提供者的简单问题。
I have one screen name is intro.dart , it has 3 widgets in the widget tree. 我有一个屏幕名称是intro.dart ,它在小部件树中有3 个小部件。 Suppose widget "A", "B" and "C" all are
stateLess
widget. 假设小部件“ A”,“ B”和“ C”都是
stateLess
小部件。 I'm using 'Provider' package. 我正在使用“提供程序”包。 My question is, I just want to call method of "A" widget while clicked on on button of "C" widget.
我的问题是,我只想在单击“ C”小部件的按钮时调用“ A”小部件的方法。 how can I do by provider or Any other easy trick?
如何通过提供者或任何其他简单技巧来完成?
Well, that's impossible or at least wrongly designed. 好吧,那是不可能的,或者至少是错误设计的。 You are trying to violate the widget encapsulation and make them directly dependent.
您试图破坏小部件封装并使它们直接相关。
Depends on what exactly you want to achieve that should do the trick: 取决于要实现的目标到底该如何解决:
If it doesn't solve your current situation - please update the question with exact problem you are facing. 如果仍不能解决您当前的情况-请使用您所遇到的确切问题来更新问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.