Introduction

node-webkit.dart is a Dart package to build node-webkit apps.

To see how the node-webkit's API looks like in Dart, check out the sample application here. Just download the dart_examples.nw archive, and open it with node-webkit.

$ nw dart_examples.nw

Features

This package provides the following libraries:

  • nw_gui.dart: A wrapper to the nw_gui module
  • path.dart: A wrapper to the path module
  • node_filesystem.dart: A wrapper to the fs module
  • dart_filesystem.dart: A complement to the node-filesystem library, wich provides the FileSystemEntity, File, Directory and Link classes, so you can access the filesystem just as you would do with dart:io
  • os.dart: A wrapper to the OS module
  • nodejs_module_wrapper.dart: A helper library for wrapping nodejs's modules

Quick Start

  • Create a Dart package (you can follow the instructions here)
  • Add node-webkit.dart as a dependency in pubspec.yaml file
name: my_app
 dependencies:
   node_webkit: any
  • Update dependencies:
$ pub get
  • Create a package.json file in web folder
{
  "name": "nw-demo",
  "main": "index.html"
}
  • Create a index.html file in web folder
<!DOCTYPE html>
<html>
  <head>
    <title>node-webkit.dart example</title>
  </head>
  
  <body>
    <script type="application/dart" src="index.dart"></script>
    <script src="packages/node_webkit/node_webkit.js"></script>
    <script src="packages/browser/dart.js"></script>

    <p id="msg"></p>
  </body>
</html>
  • And finally, create a index.dart file in web folder

import 'dart:html';
import 'package:node_webkit/nw_gui.dart' as gui;

main() {
  querySelector("#msg").text = "Hello, ${getUsername()}!";
}

String getUsername() {
  return gui.App.argv.length > 0 ? gui.App.argv[0] : "Unknown";
}

  • You can compile your app with dart2js
$ dart2js -o web/index.dart.js web/index.dart
$ nw web/ User

Libraries

dart_filesystem

Classes to handle filesystem operations.

node_filesystem

Utilities for handling filesystem operations.

nodejs_module_wrapper

Utility classes for wrapping nodejs's modules.

nw_gui

A Wrapper to the nw.gui module

os

Provides a few basic operating-system related utility functions.

path

Collection of functions to handle file paths.