Last updated:
0 purchases
flutter socket plugin
Language: English | 中文简体
FlutterSocket #
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 #
Video #
video url: https://www.youtube.com/watch?v=fmtwYHeOvE0
Add dependency #
dependencies:
flutter_socket_plugin: lastest version
copied to clipboard
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");
});
}
copied to clipboard
Steps #
Create socket :
await flutterSocket.createSocket("192.168.8.120", 10007, timeout: 20);
copied to clipboard
Connect connect :
flutterSocket.tryConnect();
copied to clipboard
Send message send :
flutterSocket.send(textEditingController.text);
copied to clipboard
Disconnect disconnect :
flutterSocket.tryDisconnect();
copied to clipboard
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.
Copyright & License #
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👇:
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.