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
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.
- mqtt5_client
A server and browser based MQTT Version 5 client for Dart supporting TCP and WebSockets.
92Compare - mqtt_client
A Dart MQTT client supporting TCP, WebSocket, secure connections and all QoS levels.
91Compare - web_socket_client
A simple WebSocket client for Dart with automatic reconnection logic.
68Compare - action_cable
ActionCable client port in dart for web, dartVM and flutter
41Compare
Works with
Packages commonly used together with socket_io_client: ones it builds on, ones built on it, and its own family.
- websocket_io_client depends on itLightweight bindings for browser APIs via JS interop
- loggingsocket_io_client depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- web_socketsocket_io_client depends on itAn easy-to-use library for communicating with WebSockets that has multiple implementations.
- socket_io_commonsocket_io_client depends on itSocket.io common parser library for Dart.
- laravel_echo_nullBuilt on socket_io_clientLaravel Echo implementation for Flutter supporting Socket.io and Pusher