dint-dev/universal_io

It's not working for web builds

hackerhgl opened this issue · 1 comments

I get this error during compil time import 'package:universal_io/io.dart';

Compiler message:
/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/io_impl_js/overrides.dart:81:29: Error: A value of type 'IOOverrides/*1*/' can't be assigned to a variable of type 'IOOverrides/*2*/'.
 - 'IOOverrides/*1*/' is from 'dart:io'.
 - 'IOOverrides/*2*/' is from 'package:universal_io/src/io_impl_js/overrides.dart' ('/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/io_impl_js/overrides.dart').
    return IODriver.current.ioOverrides;
                            ^
/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/io_impl_js/overrides.dart:92:20: Error: The argument type 'IOOverrides/*1*/' can't be assigned to the parameter type 'IOOverrides/*2*/'.
 - 'IOOverrides/*1*/' is from 'package:universal_io/src/io_impl_js/overrides.dart' ('/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/io_impl_js/overrides.dart').
 - 'IOOverrides/*2*/' is from 'dart:io'.
      ioOverrides: overrides,
                   ^
/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/io_impl_js/overrides.dart:198:24: Error: The argument type 'IOOverrides/*1*/' can't be assigned to the parameter type 'IOOverrides/*2*/'.
 - 'IOOverrides/*1*/' is from 'package:universal_io/src/io_impl_js/overrides.dart' ('/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/io_impl_js/overrides.dart').
 - 'IOOverrides/*2*/' is from 'dart:io'.
          ioOverrides: overrides,
                       ^
/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/driver/driver_impl_js.dart:68:19: Error: The argument type 'IODriver/*1*/' can't be assigned to the parameter type 'IODriver/*2*/'.
 - 'IODriver/*1*/' is from 'package:universal_io/src/driver/driver_impl_vm.dart' ('/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/driver/driver_impl_vm.dart').
 - 'IODriver/*2*/' is from 'package:universal_io/src/driver/driver_impl_js.dart' ('/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/driver/driver_impl_js.dart').
    defaultValue: defaultIODriver,
                  ^
/Users/hackerhgl/.pub-cache/hosted/pub.dartlang.org/universal_io-1.0.0/lib/src/driver/default_impl_browser.dart:40:30: Error: The class 'NetworkInterfaceOverrides' is abstract and can't be instantiated.
  networkInterfaceOverrides: NetworkInterfaceOverrides(),

When I import package from import 'package:universal_io/prefer_universal/io.dart'; app compiles successfully but I get Javascript error in chrome console.

dart_sdk.js:5291 Uncaught (in promise) Error: Unsupported operation: Platform._operatingSystem
    at Object.throw_ [as throw] (dart_sdk.js:4011)
    at Function._operatingSystem (dart_sdk.js:56675)
    at Function.get operatingSystem [as operatingSystem] (dart_sdk.js:56724)
    at get _operatingSystem (dart_sdk.js:56637)
    at Function.desc.get [as _operatingSystem] (dart_sdk.js:5037)
    at get isLinux (dart_sdk.js:56649)
    at Function.desc.get [as isLinux] (dart_sdk.js:5037)
    at Object.main$ [as main] (main.dart:10)
    at main$ (web_entrypoint.dart:8)
    at main$.next (<anonymous>)
    at onValue (dart_sdk.js:41054)
    at _RootZone.runUnary (dart_sdk.js:40940)
    at _FutureListener.thenAwait.handleValue (dart_sdk.js:36685)
    at handleValueCallback (dart_sdk.js:37185)
    at Function._propagateToListeners (dart_sdk.js:37217)
    at async._AsyncCallbackEntry.new.callback (dart_sdk.js:36973)
    at Object._microtaskLoop (dart_sdk.js:41153)
    at _startMicrotaskLoop (dart_sdk.js:41159)
    at dart_sdk.js:37420

Here's my flutter doctor logs:

[✓] Flutter (Channel master, v1.15.4-pre.134, on Mac OS X 10.15.3 19D76, locale en-PK)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Chrome - develop for the web
[!] Android Studio (version 3.5)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.42.1)
[✓] Connected device (3 available)

Dart version:
Dart VM version: 2.7.1 (Thu Jan 23 13:02:26 2020 +0100) on "macos_x64"

Thanks for the bug report! :) I was able to reproduce this, improve tests, and fix it. The new version has been uploaded to Pub.