universal_io 0.1.1 copy "universal_io: ^0.1.1" to clipboard
universal_io: ^0.1.1 copied to clipboard

outdated

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

example/universal_io.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 = ExampleIODriver();

  // You can now use 'dart:io' APIs
  final socket = await Socket.connect("google.com", 80);
  socket.close();
}

class ExampleIODriver extends IODriver {
  // An example of altering behavior of a socket API
  @override
  Future<Socket> connectSocket(host, int port,
      {sourceAddress, Duration timeout}) {
    print("Attempting to connect to '$host:$port'");
    return super.connectSocket(host, port);
  }
}
212
likes
0
pub points
99%
popularity

Publisher

verified publisherdint.dev

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

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

http, raw, stream_channel, typed_data

More

Packages that depend on universal_io