lysocket 0.0.2

Flutter Android iOS

lysocket is a socket client.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:lysocket/lysocket.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    connect();
    Lysocket.receiving();
    Lysocket.setCallBack(this.test);
  }

  Future<void> sendMsg(String message) async {
    String result = await Lysocket.sendMsg(message);
    print(result);
  }

  Future<void> connect() async {
    String result = await Lysocket.connect("192.168.0.110", 5566);
    print(result);
  }

  test(String str){
    print("==========>$str");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Container(
          padding: EdgeInsets.all(10),
          child: new TextField(
            decoration: InputDecoration(
              labelText: "输入要发送的内容",
              labelStyle: TextStyle(color: Colors.blue, fontSize: 14),
            ),

            onSubmitted: (val){
              sendMsg(val);
            },
          ),
        ),
      ),
    );
  }
}
0
likes
70
pub points
0%
popularity

lysocket is a socket client.

Homepage

Documentation

API reference

Uploader

echojohnwick@gmail.com

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on lysocket