Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Vibali Joshi vibalijoshi

🎯
Focusing
View GitHub Profile
@vibalijoshi
vibalijoshi / main.dart
Created Oct 12, 2021
Final WebSocket Flutter Demo
View main.dart
import 'package:flutter/material.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:web_socket_channel/io.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@vibalijoshi
vibalijoshi / main.dart
Created Oct 12, 2021
Connect to the echo WebSocket server
View main.dart
class MyHomePage extends StatefulWidget {
WebSocketChannel channel = IOWebSocketChannel.connect("wss://ws.ifelse.io/");
@override
MyHomePageState createState() {
return MyHomePageState();
}
}
class MyHomePageState extends State<MyHomePage> {
TextEditingController _controller = TextEditingController();
@vibalijoshi
vibalijoshi / main.dart
Created Oct 12, 2021
Boiler code template for WebSocket example
View main.dart
import 'package:flutter/material.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:web_socket_channel/io.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(