below is my websocket provider .it doesn't even hit to the server when I called from block builder
I can connect to the server without bloc, I tried a lot examples but failed
I need help guys , thanks
any example about flutter bloc with web_socket_channel
WebSocket provider
static final String wsRelationUrl = "ws://127.0.0.1:8080/chat/";
final IOWebSocketChannel _channel =
IOWebSocketChannel.connect(wsRelationUrl, headers: headers);
WebSocketProvider();
@override
Future<void> disconect() async {
if (_channel != null) {
_channel.sink.close();
}
}
@override
Future<Stream> messages() async {
if (_channel != null) {
return _channel.stream;
}
return null;
}
@override
Future<void> sendMessage(String message) async {
if (_channel != null) {
return _channel.sink.add(message);
}
}
}