'How to add headers to socketIO in flutter

I try to connect socket io in dart. I use socket_io_client: ^2.0.0-beta.4-nullsafety.0 for connection and use this code to connect:

Socket socket = io(
    '$server_address',
   OptionBuilder()
      .setTransports(['websocket'])
      .disableAutoConnect()
       .setExtraHeaders({'authorization': "$token"})
       .build());
socket.connect();

And it connects successfully. But, my headers (authorization) are not sent to the server. I also check my request and response with inspect of google chrome to make sure:

Screenshot

So, How can I send the headers with socket io?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source