Usage of local dart library

2019-07-23 18:07发布

问题:

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 think I am missing something.

I have read http://pub.dartlang.org/doc/package-layout.html but this did not help me either.

回答1:

You need to ensure that the name you're using as the package matches that in pubspec.yaml.

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