Karlo Kajba Šimanić
Karlo Kajba Šimanić

Reputation: 292

Error: Couldn't resolve the package 'universal_io' in 'package:universal_io/io.dart'

I tried importing a flutter package called PackageInfoPlus, more specifically package_info_plus: ^1.4.0. After that, everything crashed. I couldn't run the application anymore. I removed the package from the project but it still didn't work.It started giving me a whole bunch of error which I've put down below. Apparently, this universal_io script isn't working.

Invalid depfile: /home/karlo/Documents/Razvoj softvera 2022/flutter_code/freelanceMobileApp/.dart_tool/flutter_build/6a062cf2fdec4fa353179b54b6dcc33b/kernel_snapshot.d
Invalid depfile: /home/karlo/Documents/Razvoj softvera 2022/flutter_code/freelanceMobileApp/.dart_tool/flutter_build/6a062cf2fdec4fa353179b54b6dcc33b/kernel_snapshot.d
Error: Couldn't resolve the package 'universal_io' in 'package:universal_io/io.dart'.
lib/xmpp_stone/src/Connection.dart:3:8: Error: Not found: 'package:universal_io/io.dart'
import 'package:universal_io/io.dart';
       ^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:3:8: Error: Not found: 'package:universal_io/io.dart'
import 'package:universal_io/io.dart';
       ^
lib/xmpp_stone/src/connection/XmppWebsocketApi.dart:2:8: Error: Not found: 'package:universal_io/io.dart'
import 'package:universal_io/io.dart';
       ^
lib/xmpp_stone/src/Connection.dart:465:32: Error: Type 'X509Certificate' not found.
  bool _validateBadCertificate(X509Certificate certificate) {
                               ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:18:3: Error: Type 'Socket' not found.
  Socket? _socket;
  ^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:60:10: Error: Type 'SecureSocket' not found.
  Future<SecureSocket?> secure(
         ^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:62:7: Error: Type 'SecurityContext' not found.
      SecurityContext? context,
      ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:63:21: Error: Type 'X509Certificate' not found.
      bool Function(X509Certificate certificate)? onBadCertificate,
                    ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketApi.dart:20:10: Error: Type 'SecureSocket' not found.
  Future<SecureSocket?> secure(
         ^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketApi.dart:22:7: Error: Type 'SecurityContext' not found.
      SecurityContext? context,
      ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketApi.dart:23:21: Error: Type 'X509Certificate' not found.
      bool Function(X509Certificate certificate)? onBadCertificate,
                    ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/Connection.dart:419:12: Error: The method 'cast' isn't defined for the class 'Object'.
 - 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing method, or defining a method named 'cast'.
          .cast<List<int>>()
           ^^^^
lib/xmpp_stone/src/Connection.dart:465:32: Error: 'X509Certificate' isn't a type.
  bool _validateBadCertificate(X509Certificate certificate) {
                               ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:18:3: Error: 'Socket' isn't a type.
  Socket? _socket;
  ^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:26:44: Error: 'Socket' isn't a type.
    await Socket.connect(host, port).then((Socket socket) {
                                           ^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:26:11: Error: The getter 'Socket' isn't defined for the class 'XmppWebSocketIo'.
 - 'XmppWebSocketIo' is from 'package:jobscape/xmpp_stone/src/connection/XmppWebsocketIo.dart' ('lib/xmpp_stone/src/connection/XmppWebsocketIo.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Socket'.
    await Socket.connect(host, port).then((Socket socket) {
          ^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:62:7: Error: 'SecurityContext' isn't a type.
      SecurityContext? context,
      ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:63:21: Error: 'X509Certificate' isn't a type.
      bool Function(X509Certificate certificate)? onBadCertificate,
                    ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketIo.dart:65:12: Error: The getter 'SecureSocket' isn't defined for the class 'XmppWebSocketIo'.
 - 'XmppWebSocketIo' is from 'package:jobscape/xmpp_stone/src/connection/XmppWebsocketIo.dart' ('lib/xmpp_stone/src/connection/XmppWebsocketIo.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'SecureSocket'.
    return SecureSocket.secure(_socket!, onBadCertificate: onBadCertificate);
           ^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketApi.dart:22:7: Error: 'SecurityContext' isn't a type.
      SecurityContext? context,
      ^^^^^^^^^^^^^^^
lib/xmpp_stone/src/connection/XmppWebsocketApi.dart:23:21: Error: 'X509Certificate' isn't a type.
      bool Function(X509Certificate certificate)? onBadCertificate,
                    ^^^^^^^^^^^^^^^

I've also tried running flutter doctor and flutter clean commands. Output of flutter doctor:

enter image description here

Upvotes: 1

Views: 650

Answers (1)

Karlo Kajba Šimanić
Karlo Kajba Šimanić

Reputation: 292

I've managed to fix this by adding universal_io: ^2.0.4 in the dependencies of the project (pubspec.yaml file). The cause of disappearance of this package is still unkown.

Upvotes: 1

Related Questions