问题描述
我在dart lib目录中创建了一些本地库。
对于web目录中每个新创建的文件夹,这些库在dart包中都可见。然而,当我试图使用dart的包命名,例如package:reg / name.dart访问它们时,系统总是产生一个错误。
I have created some local libraries in my dart lib directory. These libraries are visible in dart packages for each newly created folder in the web directory. However, when I attempt to access them using the dart's package nomenclature eg package:reg/name.dart, the system always generates an error.
。
我已阅读,但这并没有帮助我。
I have read http://pub.dartlang.org/doc/package-layout.html but this did not help me either.
推荐答案
您需要确保您用作包的名称与pubspec.yaml中的名称匹配。
You need to ensure that the name you're using as the package matches that in pubspec.yaml.
例如。如果在pubspec.yaml中有 name:my_app
,并且您的文件位于 lib\my_library.dart
使用 import'软件包:my_app / my_library.dart';
。
Eg. if in pubspec.yaml you havename: my_app
and your file is at lib\my_library.dart
then you need to use import 'package:my_app/my_library.dart';
.
这篇关于本地dart库的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!