我正在按照本指南将我的项目迁移到空安全:https://dart.dev/null-safety/migration-guide
但是我在使用 dart migrate
命令时遇到了这个问题:
FileSystemException(path=C:\Program Files\Dart\dart-sdk\version; message=Cannot open file)
#0 _PhysicalFile.readAsStringSync (package:analyzer/file_system/physical_file_system.dart:184:7)
#1 FolderBasedDartSdk.languageVersion (package:analyzer/src/dart/sdk/sdk.dart:399:12)
#2 ContextBuilder.findSdk (package:analyzer/src/context/builder.dart:271:40)
#3 ContextBuilder.createSourceFactoryFromWorkspace (package:analyzer/src/context/builder.dart:218:19)
#4 ContextBuilder.buildDriver (package:analyzer/src/context/builder.dart:120:9)
#5 ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:94:37)
#6 new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:55:36)
#7 MigrationCliRunner.contextCollection (package:nnbd_migration/migration_cli.dart:544:28)
#9 MigrationCliRunner.run (package:nnbd_migration/migration_cli.dart:703:9)
#10 MigrateCommand.run (package:nnbd_migration/migration_cli.dart:185:72)
#11 CommandRunner.runCommand (package:args/command_runner.dart:196:27)
#12 DartdevRunner.runCommand (package:dartdev/dartdev.dart:199:30)
#13 CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#14 new Future.sync (dart:async/future.dart:218:31)
#15 CommandRunner.run (package:args/command_runner.dart:112:14)
#16 runDartdev (package:dartdev/dartdev.dart:53:29)
#17 main (file:///C:/b/s/w/ir/cache/builder/src/third_party/dart/pkg/dartdev/bin/dartdev.dart:11:9)
#18 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:279:32)
#19 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
飞镖版:
Dart SDK version: 2.12.1 (stable) (Wed Mar 10 10:18:47 2021 +0100) on "windows_x64"
颤动版本:
Flutter 2.0.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8962f6dc68 (3 days ago) • 2021-03-11 13:22:20 -0800
Engine • revision 5d8bf811b3
Tools • Dart 2.12.1
更新 SDK 约束:
environment:
sdk: ">=2.12.0 <3.0.0"
我的环境变量包含以下路径:<PATH_TO_SDK>\flutter\bin
答案 0 :(得分:0)
在 Windows 中打开注册表编辑器并搜索 (Ctrl + F) 以查找“DART_SDK”。如果不正确,请更新条目。
重新启动您的 PC 以保留任何更改。