简体   繁体   English

导入Dart包

[英]Importing Dart package

I've uploaded my package via Pub and it all seemed to work fine. 我已经通过Pub上传了我的包裹,而且一切正常。 The official page can be found here . 官方页面可以在这里找到。 The problem is, that I am unable to open this package in my sample project. 问题是,我无法在示例项目中打开此程序包。 I've added viltage: any to sample's pubspec.yaml and then presseed Pub Get. 我在样本的pubspec.yaml中添加了viltage viltage: any ,然后按下Pub Get。 The output was: 输出为:

Resolving dependencies...
+ viltage 0.0.1
Changed 1 dependency!

Which indicates that it all worked (again), but the viltage package wasn't in the packages folder. 这表明一切正常(再次),但是viltage软件包不在packages文件夹中。 Then I've tried adding this line: 然后,我尝试添加此行:

import 'package:viltage/viltage.dart';

to the sample's main.dart file. 到样本的main.dart文件。 The file viltage.dart is present in the package. 软件包中包含文件viltage.dart。 It said that the target URI does not exist and suggested: "Add dependency on package 'viltage'" 它说目标URI不存在,并建议:“添加对程序包'viltage'的依赖”

The problem I am struggeling with is that I can't use the package I've uploaded to pub. 我苦苦挣扎的问题是我无法使用上传到pub的软件包。

I saw your source on Github, you have to use the Pub Package Layout to publish a Package. 我在Github上看到了您的源代码,您必须使用Pub Package Layout来发布Package。

your code is a web app not a Dart package. 您的代码是网络应用程序,而不是Dart程序包。

只能从其他软件包中导入lib目录中的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM