title: How to send message to specific user using socket_io_client flutter package
body: <p>I am trying to build an chat apps using socket.io and node.js for backend and flutter for frontend... so far I have been trying to send message to all connected user, is there a way to send message to specific user? here is part of my backend code</p>
  <pre><code>io.on('connection', (socket) =&gt; {
    console.log(`id: ${socket.id}`)
    socket.on('send_message', (msg) =&gt; {
      var detail = JSON.parse(msg)
      socket.in(detail[&quot;receiver&quot;]).emit('to_user', msg)
    })
  });
  </code></pre>
  <p>in flutter I am using socket_io_client package (<a href="https://pub.flutter-io.cn/packages/socket_io_client" rel="nofollow noreferrer">https://pub.flutter-io.cn/packages/socket_io_client</a>) but I don't know how to emit message for specific user
  here is part of code for frontend</p>
  <pre><code>StreamController&lt;String&gt; _data = StreamController&lt;String&gt;();
  
    socket.on('send_message', (x) {
        _data.sink.add(x);
    });
  
    sendChat(String msg, String sender, String receiver) {
      Map map = {&quot;msg&quot;: msg, &quot;snd&quot;: sender, &quot;rcv&quot;: receiver};
      var mapbody = json.encode(map);
      socket.emit('send_message', mapbody);
    }
  
  Stream&lt;String&gt; get sendChat =&gt; _data.stream;
  </code></pre>