【问题标题】:isn't defined for the class 'BuildContext没有为类“BuildContext”定义
【发布时间】:2021-06-19 05:29:41
【问题描述】:

如何解决这个问题

/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dar
t:276:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'Bu
ildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/p
ackages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inh
eritFromWidgetOfExactType'.
        context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie_audio-1.0.0+1/lib/src/chewie_pla
yer.dart:101:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the cl
ass 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/p
ackages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inh
eritFromWidgetOfExactType'.
        context.inheritFromWidgetOfExactType(_ChewieAudioControllerProvider)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^FAILURE: Build failed with an exception.
  • 在哪里: 脚本 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' 行:1035

  • 出了什么问题: 任务 ':app:compileFlutterBuildRelease' 执行失败。

Process 'command 'C:\src\flutter\bin\flutter.bat'' 以非零退出值 1 结束

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以 获得更多的日志输出。运行 --scan 以获得完整的见解。

  • 通过https://help.gradle.org获得更多帮助

在 1m 56s 内构建失败 正在运行 Gradle 任务“assembleRelease”... 运行 Gradle 任务 'assembleRelease'... 完成 118.6 秒 Gradle 任务 assembleRelease 失败,退出代码为 1

【问题讨论】:

    标签: android flutter entity-framework gradle flutter-layout


    【解决方案1】:

    您使用的似乎是旧版本的chewie。 0.9.10 支持旧版本的 Flutter。在最新版本的 Flutter 中,inheritFromWidgetOfExactType 已被弃用,取而代之的是 dependOnInheritedWidgetOfExactType。这个问题已在chewie 0.10.4 版本中得到修复。

    升级您的pubspec.yaml 中的版本号。例如到最新版本:

    chewie: ^1.2.2
    

    【讨论】:

      猜你喜欢
      • 2021-02-11
      • 2021-09-01
      • 2021-09-17
      • 2021-07-26
      • 2021-04-15
      • 2021-06-19
      • 2021-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多