How to create libraries for Dart?

天涯浪子 提交于 2021-02-08 13:12:03

问题


How can I create libraries using Dart?

I want to start porting some JavaScript (and other languages) libraries I've created to Dart.


回答1:


Just put this in your library file (first place):

library mylibraryname;

You can then import this lib with:

import "path/to/mylibraryname.dart";

Other options are available, for example part which acts as include.

For a more in-depth tutorial I recommend you this blog post from Dartwatch.




回答2:


stagehand is the most simply.

Usage

mkdir fancy_project
cd fancy_project
stagehand package-simple

Stagehand templates

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.

Installation

If you want to use Stagehand on the command line, install it using pub global activate:

pub global activate stagehand


来源:https://stackoverflow.com/questions/10157598/how-to-create-libraries-for-dart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!