How to create libraries for Dart?
Asked Answered
P

2

10

How can I create libraries using Dart?

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

Pastypat answered 14/4, 2012 at 21:41 Comment(0)
M
12

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.

Moussaka answered 15/4, 2012 at 6:52 Comment(2)
Must the library file name match its declared library name? For example, if I declare "libary foo" in a file, must the file be named "foo.dart"?Pictor
Link appears to be dead :(Ahab
E
1

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
Exasperation answered 5/1, 2020 at 4:29 Comment(1)
This project (stagehand) has been discontinued.Winstonwinstonn

© 2022 - 2024 — McMap. All rights reserved.