A cross-platform implementation of dart:io that works on all platforms, including browsers.
Universal IO is a Dart package that provides a cross-platform implementation of the standard `dart:io` library, enabling its use in browser environments where it's normally unavailable. It solves the problem of writing platform-agnostic code for I/O operations by offering a drop-in replacement for `dart:io` imports, particularly for HTTP client functionality.
Dart developers building applications that need to run on both server-side and client-side (browser) platforms, especially those requiring consistent HTTP client behavior across environments.
Developers choose Universal IO because it eliminates the need for platform-specific I/O code, provides a seamless transition from `dart:io` with minimal changes, and offers browser-compatible HTTP client functionality with helpful debugging tools for cross-origin requests.
Cross-platform 'dart:io', including browser-compatible HttpClient.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows direct substitution of dart:io imports with package:universal_io, minimizing code changes for cross-platform compatibility, as shown in the getting started example.
Provides BrowserHttpClient using XMLHttpRequest with WASM compatibility and automatic text streaming for UTF-8 responses, enabling consistent HTTP client behavior across platforms.
Error messages include detailed guidance on cross-origin issues and CORS credentials mode, demonstrated in the README with examples for fixing common browser request problems.
Makes methods like Platform.isAndroid functional in browsers, providing consistent platform-agnostic code for environment detection without platform-specific checks.
Inherits browser constraints such as same-origin policy and delayed HTTP connection creation until request.close(), diverging from native dart:io behavior and limiting flexibility.
Does not support all dart:io functionalities in browsers, focusing primarily on HTTP client and select classes, which may require additional packages for full I/O operations.
Requires runtime type checks (e.g., for BrowserHttpClientRequest) to enable browser-specific settings like credentials mode, adding boilerplate and potential for errors.