Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simplest Dart Library Sample
library animals;
/**
* This is the sample dart library file, with all the library classes in this file.
*
*/
// First class
class Dog
{
String name;
void woof()
{
// do something
}
}
/**
* Another class
*/
class Cat
{
String name;
void sleep()
{
// do something
}
}
/*
* This file imports the animals library and demonstrates how to
* import it
*/
import 'animals.dart';
//use library animal classes
Dog fido = new Dog();
Cat snoozy = new Cat();
@smerz

This comment has been minimized.

Show comment
Hide comment
@smerz

smerz Feb 6, 2014

Creating libraries in Dart confused me at first. After I figured how to do, I thought I should document it, because its pretty simple once you know. The recommended approach is to use multiple files for libraries, but this works fine for simple scenarios.

Owner

smerz commented Feb 6, 2014

Creating libraries in Dart confused me at first. After I figured how to do, I thought I should document it, because its pretty simple once you know. The recommended approach is to use multiple files for libraries, but this works fine for simple scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment