我该如何使用Dart创建库?
我想开始将我创建的一些JavaScript(和其他语言)库移植到Dart。
只需将以下内容放入您的库文件中(第一行):
library mylibraryname;
然后你可以使用以下命令导入该库:
import "path/to/mylibraryname.dart";
还有其他选项可供选择,例如part
,它可以充当包含文件的作用。
如果需要更深入的教程,我建议您阅读这篇来自Dartwatch的博客文章。
stagehand 是最简单的。
mkdir fancy_project
cd fancy_project
stagehand package-simple
console-full - A command-line application sample.
package-simple - A starting point for Dart libraries or applications.
server-shelf - A web server built using the shelf package.
web-angular - A web app with material design components.
web-simple - A web app that uses only core Dart libraries.
web-stagexl - A starting point for 2D animation and games.
如果您想在命令行上使用Stagehand,请使用pub global activate进行安装:
pub global activate stagehand