flutter_socket_plugin 3.0.0 copy "flutter_socket_plugin: ^3.0.0" to clipboard
flutter_socket_plugin: ^3.0.0 copied to clipboard

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 and so on.

If you need other functions, you can expand on this basis. #

Demo #

Demo

Video #

video url: https://www.youtube.com/watch?v=fmtwYHeOvE0

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👇:

16
likes
150
pub points
44%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_socket_plugin