Pregunta

How can I create libraries using Dart?

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

¿Fue útil?

Solución

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.

Otros consejos

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top