Home > Software design >  is there any way to connect http web socket in flutter?
is there any way to connect http web socket in flutter?

Time:09-01

is there any way to connect an HTTP web socket in a flutter because I want to connect the socket using HTTP method and get response from socket

CodePudding user response:

HTTP (https://) and WebSocket (ws://) are two different protocol.

WebSocket is a framed and bidirectional protocol. On the contrary, to this, HTTP is a unidirectional protocol functioning above the TCP protocol.

As WebSocket protocol is capable to support continual data transmission, it’s majorly used in real-time application development. HTTP is stateless and is used for the development of RESTful and SOAP applications. Soap can still use HTTP for implementation, but REST is widely spread and used.

In WebSocket, communication occurs at both ends, which makes it a faster protocol. In HTTP, the connection is built at one end, making it a bit sluggish than WebSocket.

Here is the TUTORIAL on how you can use WebSocket in flutter

CodePudding user response:

Try taking a look at https://pub.dev/packages/dio

Is as simple as doing:

final Dio dio = Dio();
void main() async {
    var response = await dio.get('http://www.google.com');
}
  • Related