在项目中导入一个Dart文件

huangapple go评论105阅读模式
英文:

Flutter - Import a dart file within the project

问题

我尝试导入 auth_user.dart,但出现以下错误提示:
"URI的目标不存在"

这是我的项目:
在项目中导入一个Dart文件

我尝试了以下导入方式:

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"

Here's my project:
在项目中导入一个Dart文件

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

huangapple
  • 本文由 发表于 2023年6月12日 20:58:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76456902.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定