Skip to content
pubscout

socket_io_client

3.1.6, released 5 months ago by an unverified publisher

Dartlang port of socket.io-client for web, flutter, and dartvm

WASM-ready
$ flutter pub add socket_io_client
Source repository

What it does

Provides a client implementation to connect to Socket.io servers from Dart and Flutter applications. Supports web, Android, iOS, Windows, macOS, and Linux platforms using WebSockets.

AI-written summary of version 3.1.6, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need real-time, bidirectional event-based communication with a Socket.io backend.
  • Building cross-platform Flutter or pure Dart applications that require WebSocket connectivity with Socket.io.

Skip it when

  • You are using simple REST endpoints where standard HTTP requests are sufficient.
  • Your backend does not use the Socket.io protocol.

Strengths

  • Supports reconnection logic, custom headers, and explicit transport settings.
  • Compatible across web, desktop, and mobile Flutter environments.

Weaknesses

  • Socket instances are cached by scheme, port, and host, requiring careful handling of configuration options on initial creation.
  • Extra headers cannot be sent on the WebSocket handshake on web browsers.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
4

On macOS, ensure network client entitlements are configured. On Android/iOS, check network security policies for HTTP connections if not using HTTPS.

import 'package:socket_io_client/socket_io_client.dart' as IO;

main() {
  IO.Socket socket = IO.io('http://localhost:3000');
  socket.onConnect((_) {
    print('connect');
    socket.emit('msg', 'test');
  });
  socket.on('event', (data) => print(data));
  socket.onDisconnect((_) => print('disconnect'));
}

Alternatives

Packages that do the same job and could replace socket_io_client.

Works with

Packages commonly used together with socket_io_client: ones it builds on, ones built on it, and its own family.