Flutter:How解决系统找不到指定路径
Flutter:How to solve system can not find the path Specified
我一直在开发一个 flutter 应用程序,最近安装了三个与 firebase 相关的包 firebase_core、cloud_firestore 和 firebase_storage。但是安装后,当我尝试将它们导入 .dart 文件时,我遇到了“系统找不到指定的路径
导入'package:quiver/core.dart';'错误。那我该怎么办,这是我的 pubspec.yaml 文件。如果可以修复错误,我什至尝试将箭袋添加到 pubspec.yaml 但它没有。
name: bookecommerceapp
description: A new Flutter project.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.22.6
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
google_fonts: any
http: ^0.12.2
provider: ^4.3.3
search_page: ^1.4.0
loading: ^1.0.2
file_picker: ^2.1.6
firebase_core: ^0.7.0
cloud_firestore: ^0.16.0+1
firebase_storage: ^7.0.0
quiver: ^2.1.5
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- images/
- google_fonts/
# - imagesa_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
fonts:
- family: OpenSans
fonts:
- asset: google_fonts/OpenSans-Bold.ttf
- asset: google_fonts/OpenSans-Bolditalic.ttf
- asset: google_fonts/OpenSans-ExtraBold.ttf
- asset: google_fonts/OpenSans-ExtraBoldItalic.ttf
- asset: google_fonts/OpenSans-Light.ttf
- asset: google_fonts/OpenSans-Regular.ttf
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
这是我的完整错误堆栈跟踪
Performing hot reload...
Syncing files to device Android SDK built for x86...
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/firebase_storage.dart:11:8: Error: Error when reading '/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.5/lib/core.dart': The system cannot find the path specified.
import 'package:quiver/core.dart';
^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/lib/firebase_core.dart:10:8: Error: Error when reading '/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.5/lib/core.dart': The system cannot find the path specified.
import 'package:quiver/core.dart';
^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/firebase_core_platform_interface.dart:15:8: Error: Error when reading '/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.5/lib/core.dart': The system cannot find the path specified.
import 'package:quiver/core.dart';
^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/src/firebase_storage.dart:168:23: Error: The method 'hash2' isn't defined for the class 'FirebaseStorage'.
- 'FirebaseStorage' is from 'package:firebase_storage/firebase_storage.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/firebase_storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(app.name, bucket);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/src/reference.dart:211:23: Error: The method 'hash2' isn't defined for the class 'Reference'.
- 'Reference' is from 'package:firebase_storage/firebase_storage.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/firebase_storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(storage, fullPath);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/src/task_snapshot.dart:49:23: Error: The method 'hash2' isn't defined for the class 'TaskSnapshot'.
- 'TaskSnapshot' is from 'package:firebase_storage/firebase_storage.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/firebase_storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(storage, ref);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/lib/src/firebase_app.dart:65:23: Error: The method 'hash2' isn't defined for the class 'FirebaseApp'.
- 'FirebaseApp' is from 'package:firebase_core/firebase_core.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/lib/firebase_core.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(name, options);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/src/firebase_exception.dart:63:12: Error: The method 'hash3' isn't defined for the class 'FirebaseException'.
- 'FirebaseException' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash3'.
return hash3(plugin, code, message);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/src/firebase_options.dart:183:12: Error: The method 'hashObjects' isn't defined for the class 'FirebaseOptions'.
- 'FirebaseOptions' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashObjects'.
return hashObjects(asMap.entries);
^^^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/src/platform_interface/platform_interface_firebase_app.dart:64:23: Error: The method 'hash2' isn't defined for the class 'FirebaseAppPlatform'.
- 'FirebaseAppPlatform' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(name, options);
^^^^^
P.s 当我只将它导入到任何文件中时会发生错误
import 'package:firebase_storage/firebase_storage.dart';
我也遇到了这个问题,并且遇到了几种可能导致它的情况。
第一个: 它可能是您的环境变量中的路径损坏。您可以通过在终端中执行简单的“echo %PATH%”并删除未指向有效位置的路径来检查所有路径。
第二个: 确保您的项目路径不包含“&”,如在此问题中所述:https://github.com/flutter/flutter/issues/41547
第三个: 我发现的另一个是,在卸载 Anaconda 后,它在命令处理器注册表中遗漏了一个 AutoRun 键(在您的情况下,它可能是 Firebase)。
在 regedit 中检查以下位置是否存在损坏的链接:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Command 处理器
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command 处理器
首先在您想要的任何驱动器中创建一个新文件夹,例如 D:\
驱动器然后粘贴以下命令:
keytool -genkey -v -keystore D:\Newfolder\bingnotes.jks -keyalg RSA -keysize 2048 -validity 10000 -alias bingnotes
我一直在开发一个 flutter 应用程序,最近安装了三个与 firebase 相关的包 firebase_core、cloud_firestore 和 firebase_storage。但是安装后,当我尝试将它们导入 .dart 文件时,我遇到了“系统找不到指定的路径
导入'package:quiver/core.dart';'错误。那我该怎么办,这是我的 pubspec.yaml 文件。如果可以修复错误,我什至尝试将箭袋添加到 pubspec.yaml 但它没有。
name: bookecommerceapp
description: A new Flutter project.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.22.6
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
google_fonts: any
http: ^0.12.2
provider: ^4.3.3
search_page: ^1.4.0
loading: ^1.0.2
file_picker: ^2.1.6
firebase_core: ^0.7.0
cloud_firestore: ^0.16.0+1
firebase_storage: ^7.0.0
quiver: ^2.1.5
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- images/
- google_fonts/
# - imagesa_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
fonts:
- family: OpenSans
fonts:
- asset: google_fonts/OpenSans-Bold.ttf
- asset: google_fonts/OpenSans-Bolditalic.ttf
- asset: google_fonts/OpenSans-ExtraBold.ttf
- asset: google_fonts/OpenSans-ExtraBoldItalic.ttf
- asset: google_fonts/OpenSans-Light.ttf
- asset: google_fonts/OpenSans-Regular.ttf
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
这是我的完整错误堆栈跟踪
Performing hot reload...
Syncing files to device Android SDK built for x86...
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/firebase_storage.dart:11:8: Error: Error when reading '/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.5/lib/core.dart': The system cannot find the path specified.
import 'package:quiver/core.dart';
^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/lib/firebase_core.dart:10:8: Error: Error when reading '/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.5/lib/core.dart': The system cannot find the path specified.
import 'package:quiver/core.dart';
^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/firebase_core_platform_interface.dart:15:8: Error: Error when reading '/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.5/lib/core.dart': The system cannot find the path specified.
import 'package:quiver/core.dart';
^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/src/firebase_storage.dart:168:23: Error: The method 'hash2' isn't defined for the class 'FirebaseStorage'.
- 'FirebaseStorage' is from 'package:firebase_storage/firebase_storage.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/firebase_storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(app.name, bucket);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/src/reference.dart:211:23: Error: The method 'hash2' isn't defined for the class 'Reference'.
- 'Reference' is from 'package:firebase_storage/firebase_storage.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/firebase_storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(storage, fullPath);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/src/task_snapshot.dart:49:23: Error: The method 'hash2' isn't defined for the class 'TaskSnapshot'.
- 'TaskSnapshot' is from 'package:firebase_storage/firebase_storage.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-7.0.0/lib/firebase_storage.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(storage, ref);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/lib/src/firebase_app.dart:65:23: Error: The method 'hash2' isn't defined for the class 'FirebaseApp'.
- 'FirebaseApp' is from 'package:firebase_core/firebase_core.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/lib/firebase_core.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(name, options);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/src/firebase_exception.dart:63:12: Error: The method 'hash3' isn't defined for the class 'FirebaseException'.
- 'FirebaseException' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash3'.
return hash3(plugin, code, message);
^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/src/firebase_options.dart:183:12: Error: The method 'hashObjects' isn't defined for the class 'FirebaseOptions'.
- 'FirebaseOptions' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashObjects'.
return hashObjects(asMap.entries);
^^^^^^^^^^^
/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/src/platform_interface/platform_interface_firebase_app.dart:64:23: Error: The method 'hash2' isn't defined for the class 'FirebaseAppPlatform'.
- 'FirebaseAppPlatform' is from 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart' ('/C:/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-3.0.1/lib/firebase_core_platform_interface.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hash2'.
int get hashCode => hash2(name, options);
^^^^^
P.s 当我只将它导入到任何文件中时会发生错误
import 'package:firebase_storage/firebase_storage.dart';
我也遇到了这个问题,并且遇到了几种可能导致它的情况。
第一个: 它可能是您的环境变量中的路径损坏。您可以通过在终端中执行简单的“echo %PATH%”并删除未指向有效位置的路径来检查所有路径。
第二个: 确保您的项目路径不包含“&”,如在此问题中所述:https://github.com/flutter/flutter/issues/41547
第三个: 我发现的另一个是,在卸载 Anaconda 后,它在命令处理器注册表中遗漏了一个 AutoRun 键(在您的情况下,它可能是 Firebase)。
在 regedit 中检查以下位置是否存在损坏的链接: Computer\HKEY_CURRENT_USER\Software\Microsoft\Command 处理器 Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command 处理器
首先在您想要的任何驱动器中创建一个新文件夹,例如 D:\
驱动器然后粘贴以下命令:
keytool -genkey -v -keystore D:\Newfolder\bingnotes.jks -keyalg RSA -keysize 2048 -validity 10000 -alias bingnotes