英文:
Flutter - Import a dart file within the project
问题
我尝试导入 auth_user.dart,但出现以下错误提示:
"URI的目标不存在"
我尝试了以下导入方式:
import 'package:notes_pro/services/auth/auth_user.dart';
我做错了什么?(我相信这显而易见,提前抱歉!)
英文:
I'm trying to import auth_user.dart, and for some reason it tells me that:
"Target of URI doesn't exist"
I tried doing:
import 'package:notes_pro/services/auth/auth_user.dart';
What am I doing wrong? (I'm sure it's obvious, sorry in advance!)
答案1
得分: 1
Importing it with the full path and package name should work.
Otherwise, check if the name in the pubspec.yaml file matches what you are using in your path ('package:notes_pro/services/auth/auth_user.dart') when doing imports.
英文:
Importing it with the full path and package name should work.
Otherwise, check if the name in the pubspec.yaml file matches what you are using in your path ('package:notes_pro/services/auth/auth_user.dart') when doing imports.
答案2
得分: 0
只需使用 "auth_user.dart" 即可正常工作。这些导入使用简单的终端路径。因此,如果您在不同文件夹中有任何项目文件,您可以使用 "../second_directory/auth_user.dart"。
".. "会移动到上一级目录。
英文:
just use "auth_user.dart" and it will work. Those imports use simple terminal paths. So if you have any project file within different folders you can use "../second_directory/auth_user.dart"
".." will move up one directory
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论