kakajansh / echo

Laravel Echo for your Flutter apps.
MIT License
108 stars 70 forks source link

Error while connecting to Public channel #55

Open julianlaibach opened 3 years ago

julianlaibach commented 3 years ago

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!