Join 10350+ others. No spamming.
I promise!

Follow us at github.



luizmineo/node-webkit.dart

42

luizmineo / node-webkit.dart

Dart

build node-webkit apps with Dart.


READ ME

Unfortunatelly, I won't be able to maintain this project (and any other open-source project) in the foreseeable future. I'm terrible sorry for this, and if you are relying on this code base for your project(s), please, accept my apologies.

Also, if you have the interest, feel free to fork this repository and improve it.

For all you guys who have helped me improving this project, my sincere thanks.

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