tree: 7a56f39f54237f194671657eac0c97d7ada9f056 [path history] [tgz]
  1. example/
  2. lib/
  3. .gitignore
  4. analysis_options.yaml
  5. BUILD.gn
  6. build.yaml
  7. CHANGELOG.md
  8. dart_test.yaml
  9. LICENSE
  10. pubspec.yaml
  11. README.md
  12. STATUS.md
node_io/README.md

node_io

This library exposes Node I/O functionality in dart:io way. It wraps Node.js I/O modules (like fs and http) and implements them using abstractions provided by dart:io (like File, Directory or HttpServer).

If you are looking for direct access to Node.js API see node_interop package.

Usage

A basic example of accessing file system:

import 'package:node_io/node_io.dart';

void main() {
  print(Directory.current);
  print("Current directory exists: ${Directory.current.existsSync()}");
  print('Current directory contents: ');
  Directory.current.list().listen(print);
}

Configuration and build

Add build_node_compilers and build_runner to dev_dependencies section in pubspec.yaml of your project:

dev_dependencies:
  build_runner: # needed to run the build
  build_node_compilers:

Add build.yaml file to the root of your project:

targets:
  $default:
    sources:
      - "node/**"
      - "test/**" # Include this if you want to compile tests.
      - "example/**" # Include this if you want to compile examples.

By convention all Dart files which declare main function go in node/ folder.

To build your project run following:

pub run build_runner build --output=build/

Detailed instructions can be found in build_node_compilers package docs.

Features and bugs

Please file feature requests and bugs at the issue tracker.