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:
parent
803cea0fe4
commit
5e31b15dcf
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:web_socket_channel/io.dart';
|
||||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import '../config/app_config.dart';
|
import '../config/app_config.dart';
|
||||||
|
|
@ -31,7 +32,7 @@ class WebSocketClient {
|
||||||
|
|
||||||
final uri = Uri.parse('$baseUrl$path');
|
final uri = Uri.parse('$baseUrl$path');
|
||||||
try {
|
try {
|
||||||
_channel = WebSocketChannel.connect(
|
_channel = IOWebSocketChannel.connect(
|
||||||
uri,
|
uri,
|
||||||
headers: token != null ? {'Authorization': 'Bearer $token'} : null,
|
headers: token != null ? {'Authorization': 'Bearer $token'} : null,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue