Skip to content

Files

Latest commit

678a208 · Mar 12, 2024

History

History

node_io

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
May 13, 2020
Mar 12, 2024
May 24, 2021
May 17, 2019
Mar 12, 2024
Feb 13, 2018
Nov 21, 2020
May 17, 2019
Sep 14, 2019
May 13, 2020
Feb 7, 2018
Mar 12, 2024

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);
}

FileSystem API

This package provides a nodeFileSystem field that implements the file package's FileSystem API. This makes it possible to configure APIs written to work with generic filesystems to work with node_io in particular.

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.