web_socket_cli 0.0.2 web_socket_cli: ^0.0.2 copied to clipboard
A cross-platform WebSocket client with support for headers and followRedirects.
Web_Socket_Cli Package #
A cross-platform WebSocket client for Flutter and Dart applications. Supports headers, redirects, and works on web, iOS, and Android.
Features #
- Cross-platform support (web, iOS, Android).
- Custom headers for WebSocket connections.
- Redirect handling (on supported platforms).
Installation #
Add the following to your pubspec.yaml
:
dependencies:
web_socket_cli: ^0.0.2
Run flutter pub get or dart pub get to install the package.
Usage #
import 'package:web_socket_cli/web_socket_cli.dart';
void main() {
final client = WebSocketClient(
'wss://example.com/socket',
headers: {'Authorization': 'Bearer YOUR_TOKEN'},
followRedirects: true,
);
client.messages.listen((message) {
print('Received: $message');
});
client.send('Hello, WebSocket!');
}