Lybekk

Dart cheatsheet

Useful libraries

Standard library

Print

print('Hello, World!');

Basic function

void main() { print('Hello, World!'); }

Run Dart script from the command line

dart /path/to/script.dart

Directory

var myDir = new Directory('/home/user/dir/');

List files in a directory

var myDir = new Directory('/home/user/dir/');

void checkDir(theDir) {
  theDir.exists().then((isThere) {
    isThere ? print('exists') : print('non-existent');
    listDir(theDir);
  });
}

void listDir(theDir) {
    theDir.list(recursive: true, followLinks: false)
    .listen((FileSystemEntity entity) {
        print(entity.path);
    });
}

checkDir(myDir);

Handy resources from around the web