【发布时间】:2021-11-10 06:06:16
【问题描述】:
我想以这样的方式使用提供者包的消费者小部件,它只会在类的特定方法运行或 notifyListeners() 调用时运行。
这是一个类
Class Example with ChangeNotifier{
void exampleMethod(){
//....Do SomeThing
notifyListeners();
}
void exampleOneMethod(){
//....Do SomeThing
notifyListeners();
}
}
所以当我像这样在一些小部件中调用消费者时:
Consumer<Example>(builder:(_,ex,__)=>SomeWidget(
ex.exampleOneMethod();
)
只有在 exampleOneMethod 运行而不是在其他方法上运行时,Soo Consumer Widget 才会重新构建。
【问题讨论】:
标签: flutter flutter-dependencies flutter-provider