# universal_io 0.1.1

Supports a subset of 'dart:io' in all platforms, including the browser.




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'universal_io:0.1.1'
```
Published: 2019-02-18T21:46:46.616626Z
Expected archive SHA-256: b4d0cce4eaf430212064bb594e4213a4ead522acc5242b921d219c9efaefe2b0

Available in cache; verification: upstream_checksum
## Direct dependencies
- http: ^0.12.0
- raw: ^0.2.0
- stream_channel: ^1.6.8
- typed_data: ^1.1.6

## Package README (untrusted upstream documentation)
# Introduction
A [Dart](https://dartlang.org) package that supports a subset of [dart:io](https://api.dartlang.org/stable/2.1.1/dart-io/dart-io-library.html) in all platforms,
including the browser (where it normally doesn't work).

Typically you just import "package:universal_io/io.dart" (instead of "dart:io"):
  * In the Dart VM and Flutter, the library exports _dart:io_.
  * In browser: the library exports its own, compatible classes.

Licensed under the MIT License.
Much of the source code was adopted from the original 'dart:io' in [Dart SDK](https://github.com/dart-lang/sdk),
which was licensed under a BSD-style license. See [LICENSE](LICENSE) for all licenses.

## Development
  * Star the project at: [github.com/terrier989/dart-universal_io](https://github.com/terrier989/dart-universal_io)
  * Report issues at the [Github issue tracker](https://github.com/terrier989/dart-universal_io/issues).
  * Create pull requests if you contribute source code.

## Features
  * __Platform information__
    * Information such as operating system, locale, and stdin/stdout.
      You can override the behavior.
  * __HTTP client__
    * In browser, the connection to the server is established only after you have committed request
      body by calling `HttpClientRequest` method `close()`.
  * __File access__
    * In browsers, access to all directories and files is denied.
      You can override the behavior.
  * __Sockets__
    * In most browsers, an attempt to create sockets throws _UnsupportedError_.
      You can override the behavior.
    * In Chrome OS apps, we use [chrome.sockets.tcp](https://developer.chrome.com/apps/sockets_tcp)
      and [chrome.sockets.udp](https://developer.chrome.com/apps/sockets_udp) APIs.

# Getting started
## Add dependency
In `pubspec.yaml`:
```yaml
dependencies:
  universal_io: ^0.1.0
```

## Override behavior
```dart
import 'dart:async';

import 'package:universal_io/io.dart';
import 'package:universal_io/io_driver.dart';

void main() async {
  // Set IO driver
  IODriver.zoneLocal.defaultValue = new MyDriver();

  // Do something
  final socket = await Socket.connect("google.com", 80);
  socket.close();
}

class MyDriver extends IODriver {
  @override
  Future<Socket> connectSocket(host, int port,
      {sourceAddress, Duration timeout}) {
    print("Attempting to connect to '$host:$port'");
    return super.connectSocket(host, port);
  }
}
```

## Use Chrome OS driver
```dart
import 'package:universal_io/io.dart';
import 'package:universal_io/io_driver.dart';
import 'package:universal_io_for_chrome_os/io_driver_chrome_os.dart';

void main() async {
  // Use Chrome OS driver for IO
  IODriver.zoneLocal.defaultValue = new ChromeIODriver();
  
  // ...
}
```
## Changelog
## 0.1.0

* Added sockets, overrides, and other features.

## 0.0.1

* Initial release.






 
