我正在学习 udemy 课程的教程,最近我构建了一台新电脑,因此存储我的代码的硬盘现在是次要的。当我编译代码时,它给了我以下错误。为了更好地解释它,我在我的代码中张贴了一个警告的图片,但我很确定这是一个错误,因为它通常与导入一样。代码错误 我尝试通过从 cmd 制作默认应用程序来运行测试应用程序,并且工作正常。所以很明显,flutter doctor 没有显示错误。错误是重复的,而且很长,所以我在下面粘贴了一些。
错误-
Invalid depfile: D:\WorkSpace\Code\Flutter\Image App\image_app\.dart_tool\flutter_build\8f0d0eee9ef614ed024ca7691a333af8\kernel_snapshot.d
Invalid depfile: D:\WorkSpace\Code\Flutter\Image App\image_app\.dart_tool\flutter_build\8f0d0eee9ef614ed024ca7691a333af8\kernel_snapshot.d
Compiler message:
Error: Could not resolve the package 'http' in 'package:http/http.dart'.
lib/src/app.dart:5:8: Error: Expected ';' after this.
import 'widgets/image_list.dart;'
^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/src/app.dart:2:8: Error: Not found: 'package:http/http.dart'
import 'package:http/http.dart' show get; //Only need get so we only care about one Get fuction
^
lib/src/app.dart:5:8: Error: Error when reading 'lib/src/widgets/image_list.dart;': The system cannot find the file specified.
import 'widgets/image_list.dart;'
^
/C:/src/flutter/packages/flutter/lib/src/material/bottom_navigation_bar.dart:9:8: Error: Error when reading '/C:/Users/dluck/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/vector_math_64.dart': The system cannot find the path specified.
import 'package:vector_math/vector_math_64.dart' show Vector3;
^
/C:/src/flutter/packages/flutter/lib/widgets.dart:15:1: Error: Error when reading '/C:/Users/dluck/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/vector_math_64.dart': The system cannot find the path specified.
export 'package:vector_math/vector_math_64.dart' show Matrix4;
^
/C:/src/flutter/packages/flutter/lib/rendering.dart:31:1: Error: Error when reading '/C:/Users/dluck/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/vector_math_64.dart': The system cannot find the path specified.
export 'package:vector_math/vector_math_64.dart' show Matrix4;
^
/C:/src/flutter/packages/flutter/lib/src/widgets/implicit_animations.dart:8:8: Error: Error when reading '/C:/Users/dluck/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/vector_math_64.dart': The system cannot find the path specified.
import 'package:vector_math/vector_math_64.dart';
^
/C:/src/flutter/packages/flutter/lib/src/widgets/transitions.dart:8:8: Error: Error when reading '/C:/Users/dluck/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/vector_math_64.dart': The system cannot find the path specified.
import 'package:vector_math/vector_math_64.dart' show Matrix4;
^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:27:8: Error: Error when reading '/C:/Users/dluck/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/vector_math_64.dart': The system cannot find the path specified.
import 'package:vector_math/vector_math_64.dart';
^
/C:/src/flutter/packages/flutter/lib/foundation.dart:12:1: Error: Error when reading '/C:/Users/dluck/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/meta-1.1.8/lib/meta.dart': The system cannot find the path specified.
C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:90:4: Error: Getter not found: 'mustCallSuper'.
@mustCallSuper
^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:90:4: Error: This can't be used as metadata; metadata should be a reference to a compile-time constant variable, or a call to a constant constructor.
@mustCallSuper
^
/C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:104:4: Error: Getter not found: 'mustCallSuper'.
@mustCallSuper
^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:104:4: Error: This can't be used as metadata; metadata should be a reference to a compile-time constant variable, or a call to a constant constructor.
@mustCallSuper
^
/C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:118:4: Error: Getter not found: 'protected'.
@protected
^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:118:4: Error: This can't be used as metadata; metadata should be a reference to a compile-time constant variable, or a call to a constant constructor.
@protected
^
/C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:119:4: Error: Getter not found: 'mustCallSuper'.
@mustCallSuper
^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:119:4: Error: This can't be used as metadata; metadata should be a reference to a compile-time constant variable, or a call to a constant constructor.
@mustCallSuper
^
/C:/src/flutter/packages/flutter/lib/src/foundation/node.dart:139:4: Error: Getter not found: 'protected'.
@protected
^^^^^^^^^
C:/src/flutter/packages/flutter/lib/src/semantics/semantics.dart:3970:4: Error: This can't be used as metadata; metadata should be a reference to a compile-time constant variable, or a call to a constant constructor.
@required TextDirection thisTextDirection,
^
/C:/src/flutter/packages/flutter/lib/src/semantics/semantics.dart:3971:4: Error: Getter not found: 'required'.
@required TextDirection otherTextDirection,
^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/semantics/semantics.dart:3971:4: Error: This can't be used as metadata; metadata should be a reference to a compile-time constant variable, or a call to a constant constructor.
@required TextDirection otherTextDirection,
^
U
nhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:
package%3Ahttp%2Fhttp.dart; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFi
leSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:33:7)
#1 asFileU
ri (package:vm/kernel_front_end.dart:604:37)
#
2 writeDepfile (package:vm/kernel_front
_end.dart:799:21)
<asynchronous suspension>
#
3 FrontendCompiler.compile (package:fron
tend_server/frontend_server.dart:472:15)
<asynchronous
suspension>
#4 _FlutterFrontendCompiler.comp
ile (package:flutter_frontend_server/server.dar
t:38:22)
#5 starter (package:flutter_fronte
nd_server/server.dart:149:27)
#6 main (f
ile:///C:/b/s/w/ir/cache/builder/src/flutter/fl
utter_frontend_server/bin/starter.dart:8:30)
#7
_startIsolate.<anonymous closure> (dart:isol
ate-patch/isolate_patch.dart:305:32)
#8 _RawRec
eivePortImpl._handleMessage (dart:isolate-patch
/isolate_patch.dart:174:12)
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\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 6s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Run Code Online (Sandbox Code Playgroud)
小智 10
Invalid depfile: D:\...\f5\.dart_tool\flutter_build\8e234dd4da26339b660f6097cc2a271a\kernel_snapshot.d
Run Code Online (Sandbox Code Playgroud)
删除此位置的文件kernel_snapshot.d:kernel_snapshot.stamp
your flutter project\.dart_tool\flutter_build\8e234dd4da26339b660f6097cc2a271a
Run Code Online (Sandbox Code Playgroud)
好吧,您可以执行两个步骤来解决此问题
1. flutter clean
2. flutter pub get
Run Code Online (Sandbox Code Playgroud)
运行这些命令后应该可以解决您的问题
小智 6
我有同样的错误,我停用了 vs code。当我重新激活它时,我只是输入
flutter clean
flutter pub get
flutter run
Run Code Online (Sandbox Code Playgroud)
一切开始运转。
小智 5
有时它也会发生在我身上。我要么删除了转换后的代码,要么将其转换为命令例如,我在这里输入:
import 'dart:html';
Run Code Online (Sandbox Code Playgroud)
, 我的错误在删除或变成评论后得到修复
// import 'dart:html';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29982 次 |
| 最近记录: |