使用flutter2之后,以往的一些插件,会出现inheritFromWidgetOfExactType错误提示:如下
/D:/FlutterSDK/.pub-cache/hosted/pub.flutter-io.cn/provide-1.0.2/lib/provide.dart:570:28: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/D:/FlutterSDK/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
final widget = context.inheritFromWidgetOfExactType(_InheritedProviders);
inheritFromWidgetOfExactType方法已经不再使用了,取而代之的是dependOnInheritedWidgetOfExactType。
例如对
D:\FlutterSDK.pub-cache\hosted\pub.flutter-io.cn\provide-1.0.2\lib\provide.dart
第570行,进行修改,原有的代码
final widget = context.inheritFromWidgetOfExactType(_InheritedProviders);
改为
final widget = context.dependOnInheritedWidgetOfExactType(aspect:_InheritedProviders);