Flutter @dart=2.9 import 'dart:math';错误,dart代码无法在模拟器中运行?

7rfyedvj  于 2023-07-31  发布在  Flutter
关注(0)|答案(2)|浏览(156)

**问题:**如何解决如下所示的抖动错误&为什么会发生这种情况?
无法理解这个错误的是 * 我无法理解@dart=2.9是什么。我以前有一段时间没有运行或编码该文件了。所以,当我回来工作在这个Flutter文件项目,它扔给我这个错误?

我尝试在命令提示符下更新flutter。医生说一切正常。唯一缺少的部分是Visual Studio,但我使用Visual Studio Code。所以我想这不是问题所在。如果不是,那会是什么?我深深地思考着这个漫长的错误,无法理解。

预先给予的感激任何形式的帮助都会得到感激
**错误:*Flutter run - * 当我运行flutter run时,它总是显示以下错误。

Invalid depfile: C:\Users\14706\Desktop\Test-SETUP\New folder\This_Folder_Contains_Map_Tests_From_Top_To_Bottom_Atempts\Challenge_1\flutter_login_auth\.dart_tool\flutter_build\6494cc4bb6a11f1a583790c79662ece5\kernel_snapshot.d
Invalid depfile: C:\Users\14706\Desktop\Test-SETUP\New folder\This_Folder_Contains_Map_Tests_From_Top_To_Bottom_Atempts\Challenge_1\flutter_login_auth\.dart_tool\flutter_build\6494cc4bb6a11f1a583790c79662ece5\kernel_snapshot.d
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/firebase_database.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.9
^^^^^^^^^^^^
lib/Pages/auth/mainLoginCheck.dart:2:8: Error: Not found: 'dart:html'
import 'dart:html';
       ^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/utils/push_id_generator.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/database_reference.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/event.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/firebase_database.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/query.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.9
^^^^^^^^^^^^
../../../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_database-6.1.2/lib/src/on_disconnect.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
// @dart=2.9
^^^^^^^^^^^^

字符串

**未处理的异常,嗯...?这个错误到底是什么?

Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:dart
%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0      StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1      asFileUri (package:vm/kernel_front_end.dart:659:37)
#2      writeDepfile (package:vm/kernel_front_end.dart:799:2
1)
<asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:625:9)
<asynchronous suspension>
#4      starter
 (package:frontend_server/frontend_server.dart:1451:12)
<asynchronous suspension>
#5      main (file:///C:/b/s/w/ir/x/w/sdk/pkg/frontend_server
/bin/
frontend_server_starter.dart:10:14)
<asynchronous suspension>
FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\14706\Desktop\CODES\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\14706\Desktop\CODES\Flutter\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 28s
Running Gradle task 'assembleDebug'...                             30.1s
Exception: Gradle task assembleDebug failed with exit code 1
Error: Not found: 'dart:html'
import 'dart:html';

我以前试过在命令提示符下更新flutter。医生说一切正常。我试着看看**@=dart=2.9是什么?但还不够了解。我也试着查看错误突出显示的东西,它是'dart:html';**我不明白为什么这是一个错误?

j9per5c4

j9per5c41#

1-只需从代码中删除import 'dart:html';
2-运行flutter clean然后flutter pub get
如果不起作用,请检查this

zujrkrfu

zujrkrfu2#

导入'dart:math'而不是'dart:html'

import 'dart:math'

字符串

相关问题