fix: use IOWebSocketChannel for headers support

WebSocketChannel.connect does not accept headers parameter in
web_socket_channel 2.4.0. Use IOWebSocketChannel.connect instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-23 16:45:35 -08:00
parent 803cea0fe4
commit 5e31b15dcf
1 changed files with 2 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../config/app_config.dart';
@ -31,7 +32,7 @@ class WebSocketClient {
final uri = Uri.parse('$baseUrl$path');
try {
_channel = WebSocketChannel.connect(
_channel = IOWebSocketChannel.connect(
uri,
headers: token != null ? {'Authorization': 'Bearer $token'} : null,
);