【问题标题】:How to create libraries for Dart?如何为 Dart 创建库?
【发布时间】:2012-04-26 19:22:38
【问题描述】:

如何使用 Dart 创建库?

我想开始将我创建的一些 JavaScript(和其他语言)库移植到 Dart。

【问题讨论】:

    标签: dart dartium


    【解决方案1】:

    只要把它放在你的库文件中(第一名):

    library mylibraryname;
    

    然后您可以使用以下命令导入此库:

    import "path/to/mylibraryname.dart";
    

    其他选项可用,例如part,它充当包含。

    如需更深入的教程,我向您推荐blog post from Dartwatch

    【讨论】:

    • 库文件名必须与其声明的库名匹配吗?例如,如果我在文件中声明“libary foo”,该文件必须命名为“foo.dart”吗?
    • 链接似乎已失效:(
    【解决方案2】:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-31
      • 2017-11-19
      • 2020-10-31
      • 2015-03-02
      • 1970-01-01
      • 2014-07-06
      • 2017-12-01
      • 1970-01-01
      相关资源
      最近更新 更多