Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while connecting to Public channel #55

Open
julianlaibach opened this issue Dec 2, 2021 · 0 comments
Open

Error while connecting to Public channel #55

julianlaibach opened this issue Dec 2, 2021 · 0 comments

Comments

@julianlaibach
Copy link

Hey, im pretty new to Flutter but i followed the example and once debugging the App im getting the following Error:

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: NoSuchMethodError: Closure call with mismatched arguments: function 'onConnect'
Receiver: Closure: (dynamic, [dynamic]) => Socket from Function 'io': static.
Tried calling: onConnect(Closure: (dynamic) => void)
Found: onConnect(dynamic, [dynamic]) => Socket

My Code lives in the main.dart and is as follows:

void main() {
  runApp(MyApp());
  initWebsocket();
}

void initWebsocket() {
  // Create socket.io client
  IO.Socket socket = IO.io(
    'http://xxxxx:6001',
    IO.OptionBuilder()
        .disableAutoConnect()
        .setTransports(['websocket']).build(),
  );

  // Create echo instance
  Echo echo = new Echo({
    'broadcaster': 'socket.io',
    'client': IO.io,
  });

  // Listening public channel
  // echo.channel('testevent').listen('ExampleEvent', (e) {
  //   print(e);
  // });

  echo.connector.socket.onConnect((_) => print('connected'));
  echo.connector.socket.onDisconnect((_) => print('disconnected'));
}

My pubspec.yaml:


environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  http:
  shared_preferences: ^0.5.6+1
  dots_indicator: ^2.0.0
  flappy_search_bar: 1.4.1
  socket_io_client: ^0.9.1
  laravel_echo:

dev_dependencies:
  flutter_test:
    sdk: flutter

With my SPA via Vue everything works well, did i missed anything? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant