完整错误信息如下:

/D:/flutter/.pub-cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/delegate_widget.dart:194:18: Error: Superclass has no method named 'inheritFromElement'.return super.inheritFromElement(ancestor, aspect: aspect);^^^^^^^^^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/provider.dart:259:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/D:/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.? context.inheritFromWidgetOfExactType(type) as InheritedProvider<T>^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/provider.dart:260:19: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/D:/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorInheritedElementForWidgetOfExactType'.: context.ancestorInheritedElementForWidgetOfExactType(type)?.widget^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^FAILURE: Build failed with an exception.* Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991* What went wrong:
Execution failed for task ':flutter:compileFlutterBuildDebug'.
> Process 'command 'D:\flutter\bin\flutter.bat'' finished with non-zero exit value 1* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.orgBUILD FAILED in 7sGradle task assembleAarDebug failed with exit code 0.
  • flutter版本:2.0.4
  • provider版本:3.2.0

问题原因

provider该版本中使用了flutter2.x.x不兼容的方法,讲provider升级到新版(如provider 5.0.0)即可。

解决办法

编辑项目根目录下的【pubspec.yaml】文件,把【dependencies】下的【provider】版本改为5.0.0,以我的为例:

dependencies:flutter:sdk: flutter# The following adds the Cupertino Icons font to your application.# Use with the CupertinoIcons class for iOS style icons.cupertino_icons: ^0.1.2provider: ^5.0.0

结束!

flutter项目提示 Superclass has no method named ‘inheritFromElement‘等错误解决相关推荐

  1. Android 导入项目提示 Could not find method buildFeatures()for arguments xxx on extension ‘android

    出现该问题是因为使用了AS4.1以上的版本,只有AS4.1以上的版本才会有这个buildFeatures()函数, buildFeatures {dataBinding = true} 4.1以下的还 ...

  2. Git上传项目提示Push rejected: Push to origin/dev was rejected解决办法

    # 先从远程拉取master分支 git pull origin master --allow-unrelated-histories #然后推送即可 git push -u origin maste ...

  3. 本地项目提交代码到git仓库详细教程包含错误解决办法!!!

    1.查看远程分支 git branch -r 2.查看本地分支 git branch 二.创建和切换分支 1.创建新分支 git branch 新分支名称 2.切换分支 git checkout 分支 ...

  4. AttributeError: module librosa has no attribute output No module named numba.decorators错误解决

    https://blog.csdn.net/baidu_39629638/article/details/107873673

  5. Oracle连接工具PLSQL登录时提示初始化失败,无法锁定OCI.dll错误解决

    报错信息:  (没有登录)-PL/SQL Developer   Initialization error 无法锁定OCI dll   OracleHomeKey:   OracleHomeDir:E ...

  6. 去除Flutter项目dart文件在vscode里出现波浪号

    问题示例: 去掉Flutter项目在vscode里打开显示的蓝色波浪线解决办法:

  7. 解决Apache提示“You don‘t have permission to access...“错误

    目录 解决Apache提示"You don't have permission to access..."错误 解决Apache提示"You don't have per ...

  8. Flutter项目实操---资讯、发布动弹

    资讯: 继续接着上一次https://www.cnblogs.com/webor2006/p/13186045.html的功能往下编写,这一篇算是这个操练小项目的最后一篇笔记了,基本上经过这么将近一年 ...

  9. 使用VS Code新建编译Flutter项目

    本文的前提是你已经安装好了VS Code,并且安装了Flutter和Dart扩展插件. 1. 新建Flutter项目 查看--命令面板,或者Ctrl + Shift + P 输入 Flutter: N ...

最新文章

  1. R语言ggplot2可视化:指定标题的坐标轴位置(X轴坐标和Y轴坐标),将图像的标题(title)放置在图像内部的指定位置(customize title positon in plot)
  2. 自定义安装python,退格,方向键无法正常使用(转)
  3. 在 SAP Kyma 上使用 Redis 服务
  4. php下载当前页面,php实现当前页面点击下载文件的简单方法
  5. 【kafka】Kafka 幂等 Producer
  6. 让远程传输大文件变得更快
  7. Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=
  8. 实用技巧——获取验证码的倒计时
  9. java利用反射映射两个不同对象的属性值
  10. 前端项目开发总结:电商后台管理系统
  11. 2.7 汽车之家口碑爬虫
  12. RB-PEG2000-Pyrene,含有芘丁酸和罗丹明的PEG,Pyrene-PEG2000-Rhodamine
  13. October CMS - 快速入门 3 创建主题
  14. 网路连接配置和DNS服务?解决无线网卡连接WIFI问题(硬件和驱动没问题)?
  15. n个节点互异的拉格朗日插值基函数之和等于一证明
  16. 终极 Shell——ZSH
  17. excel写公式工具
  18. Android/iOS微信6.3.5同时发布更新 支持群视频聊天、群公告
  19. Pikachu靶场通关笔记--Sql Inject(SQL注入)
  20. 智慧养老解决方案助力家庭养老发展,全面打造智慧养老新模式-新导智能

热门文章

  1. h3c使用acl控制ftp访问_H3C三层交换机怎样利用ACL访问控制列表限制两个网段互访...
  2. GPS/RTK高精度定位系统有什么优势?
  3. .net C# 苹果消息推送 工具类
  4. 平度职教中心计算机考证
  5. Linux网络通信------accept函数
  6. Onvif Profile简介
  7. 宅家36天咸鱼翻身入职腾讯
  8. 怎么批量运营自媒体号?从做自媒体的第一天起就要思考的问题!
  9. LeetCode笔记:Biweekly Contest 87
  10. 取消Excel打开密码的两种方法