flutter - 使用flever常量最佳实践,而不是使用dependentOnInheritedWidgetOfExactType。

标签 flutter dart

我想实现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/

相关文章:

list - 使用箭头浏览列表/更改小部件

dart - Dart 中的字符串格式

flutter - DraggableScrollableSheet 在拖动时每帧重建所有子项

web - Flutter WEB,布局模板。 pop 返回 void 但期望 Bool

dart - Dart-返回字符串,而不是类的实例

dart - Flutter - 如何从类型实例化对象

Flutter Provider - 使用 ProxyProvider 的循环依赖

flutter - 如何处理键盘快捷键

Flutter Bluetooth Serial Discovery - 取消发现(流关闭)

flutter - 如何修复 "Failed assertion: line 227 pos 12: ' _allAds[id] !=null' : is not true. "?