尝试运行命令“flutter run”时出错

时间:2021-06-12 10:58:56

标签: android windows flutter gradle

我试图运行命令 'flutter run' 它给了我错误。颤振医生没有问题。我不知道错误来自哪里,我尝试运行这个flutter clean,flutter pub cache repair,flutter run。还是一样的错误。

Warning: You are using these overridden dependencies:                   
! intl 0.17.0
Running "flutter pub get" in cretello_rentors_plus_1...            34.3s
Using hardware rendering with device sdk gphone x86 arm. If you notice graphics
artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
/C:/src/flutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/dynamic_theme-1.0.1/lib/dynamic_theme.dart:25:46: Error: Method not found: 'TypeMatcher'.
    return context.ancestorStateOfType(const TypeMatcher<DynamicThemeState>());
                                             ^^^^^^^^^^^
/C:/src/flutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/dynamic_theme-1.0.1/lib/dynamic_theme.dart:25:20: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutterSDK/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'.
    return context.ancestorStateOfType(const TypeMatcher<DynamicThemeState>());  
                   ^^^^^^^^^^^^^^^^^^^
                                                                        
                                                                        
FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutterSDK\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.org

BUILD FAILED in 43s
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                        44.8s
Exception: Gradle task assembleDebug failed with exit code 1```

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

这个问题是由于您的颤振版本造成的。如果要复制其他代码,请确保先运行。

flutter clean
flutter pub get

如果这不起作用,请确保您使用正确版本的 flutter sdk。