flutter_socket_plugin 1.0.1

Flutter Android iOS

FlutterSocket is a practical cross-platform socket plugin,supports both iOS and Android.

Language: English | 中文简体

FlutterSocket #

build status Pub support

FlutterSocket is a practical cross-platform socket plugin. At present, it has realized the basic functions of client side: create, connect, send, receive, disconnect, heartbeat and so on.

Demo #

Demo

Add dependency #

dependencies:
  flutter_socket_plugin: lastest version  

Simple to use #

import 'package:flutter_socket_plugin/flutter_socket_plugin.dart';
  ///
  /// @Method: initSocket
  /// @Parameter:
  /// @ReturnType:
  /// @Description: init socket
  /// @author: waitwalker
  /// @Date: 2019-08-23
  ///
  initSocket() {
    
    /// init socket
    flutterSocket = FlutterSocket();

    /// listen connect callback
    flutterSocket.connectListener((data){
      print("connect listener data:$data");
    });

    /// listen error callback
    flutterSocket.errorListener((data){
      print("error listener data:$data");
    });

    /// listen receive callback
    flutterSocket.receiveListener((data){
      print("receive listener data:$data");
      if (data != null) {
        receiveMessage = receiveMessage + "\n" + data;
      }
      setState(() {

      });
    });

    /// listen disconnect callback
    flutterSocket.disconnectListener((data){
      print("disconnect listener data:$data");
    });

  }

Steps #

Create socket :

await flutterSocket.createSocket("192.168.8.120", 10007, timeout: 20);

Connect connect :

flutterSocket.tryConnect();

Send message send :

flutterSocket.send(textEditingController.text);

Disconnect disconnect :

flutterSocket.tryDisconnect();

Examples #

you can find all examples code here.

Future #

FlutterSocket currently implements the sending and receiving of basic String messages on the client. In the future, it will gradually improve its functions if conditions permit. If you need some functions urgently, you can continue to add functions on the basis of FlutterSocket to make the function of FlutterSocket more powerful and perfect.

This project is completely open source and the license is MIT. If you like, welcome star.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Flutter Technology and Other Communication Groups #

wechat:dbzy_duzhao

Scan QR code👇:

3
likes
90
pub points
57%
popularity

FlutterSocket is a practical cross-platform socket plugin,supports both iOS and Android.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

waitwalkerme@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_socket_plugin