【问题标题】:ThemeData inheritTheme = Theme.of(context, shadowThemeOnly: true) errorThemeData inheritTheme = Theme.of(context, shadowThemeOnly: true) 错误
【发布时间】:2021-06-04 01:51:21
【问题描述】:

颤振 2.0.1 飞镖 2.12

我在模拟器上构建 iOS 应用时遇到问题。 (iOS 14.4) 构建停止并抛出下面列出的错误:

 ** BUILD FAILED **
Xcode's output:
↳
    ../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_datetime_picker-1.4.0/lib/flutter_datetime_picker.dart:215:48: Error: No named parameter with the name 'shadowThemeOnly'.
        ThemeData inheritTheme = Theme.of(context, shadowThemeOnly: true);
                                                   ^^^^^^^^^^^^^^
    ../Developer/flutter/packages/flutter/lib/src/material/theme.dart:107:20: Context: Found this candidate, but the arguments don't match.
      static ThemeData of(BuildContext context) {
                       ^^
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
Could not build the application for the simulator.

我读到 Theme.of 已被 InheritedTheme/或 InheritTheme 替换,但是当我查看问题时,我收到了列出的文件不存在的消息(示例如下)

Unable to open 'theme.dart': Unable to read file '/Users/userName/hdk/Developer/flutter/packages/flutter/lib/src/material/theme.dart' 
(Error: Unable to resolve non-existing file '/Users/userName/hdk/Developer/flutter/packages/flutter/lib/src/material/theme.dart').

颤振医生:

[✓] Flutter (Channel stable, 2.0.1, on macOS 11.2.2 20D80 darwin-x64, locale pl-PL)
    • Flutter version 2.0.1 at /Users/paweljagla/Developer/flutter
    • Framework revision c5a4b4029c (17 hours ago), 2021-03-04 09:47:48 -0800
    • Engine revision 40441def69
    • Dart version 2.12.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/paweljagla/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (2 available)
    • iPhone 11 Pro Max (mobile) • 87DDB2A3-2284-4D85-A835-FE842809E6E9 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4
      (simulator)
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 88.0.4324.192

我尝试过:清理、更新颤振、更新软件包、重新安装颤振,但没有任何效果。如何摆脱这个错误?有什么想法吗?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    嗯,这在flutter中很常见(因为最新和最旧)我使用flutter 2.0.2并且仍然有同样的问题,但通常不是来自flutter,相反它来自包或lib,有时它很容易解决,你有两种选择:

    1. 更新软件包,或

    2. 直接编辑打包代码,解决

      a) 进入包目录

      b) 打开错误提示的文件

      c) 并删除导致错误的代码

      d) 保存并关闭文件,就是这样。

    例如,我对这个包有同样的问题:flutter_cupertino_date_picker 我编辑源代码以消除错误,

    a) 包目录:

    C:/silex/SDK/flutter/.pub-cache/git/flutter-cupertino-date-picker-38630701b92a4fd0b753f9ab38b3581a5645a629/lib/src/
    

    b) 文件:

    date_picker.dart
    

    c) 删除:'shadowThemeOnly: true'

    theme: Theme.of(context, shadowThemeOnly: true), 
    

    d) 已保存:

    theme: Theme.of(context). 
    

    另一个例子:DiagnosticableMixin

    查找错误并不总是那么容易,但它几乎总是有效,我希望它有所帮助,因为这是在软件包更新之前临时修复这些类型的错误的最佳方法。问候!。

    【讨论】:

      猜你喜欢
      • 2022-01-20
      • 2019-12-31
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-29
      • 2016-01-01
      相关资源
      最近更新 更多