我想实现RémiRousselet的Flutter中常数的最佳实践:What's the best practice to keep all the constants in Flutter?
但不建议使用inheritFromWidgetOfExactType
:
'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1.. Try replacing the use of the deprecated member with the replacement.
你能帮我用
dependOnInheritedWidgetOfExactType
实现吗?
最佳答案
我在类里面使用Provider extends InheritedWidget
这样
static Bloc of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<Provider>().bloc;
}
关于flutter - 使用flever常量最佳实践,而不是使用dependentOnInheritedWidgetOfExactType。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59751810/