Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

Dart Flutter Socket is it possible to receive a file over a socket?

Dart Flutter Socket is it possible to receive a file over a socket ? for example a picture jpeg


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

code that accepts text

Future<String> getListUsers(String request) async {
  if (request != null) {
    Socket socket;
    await Socket.connect(ip, port).then((Socket sock) {
      socket = sock;
    }).then((_) {
      socket.write('$request
');
      return socket.first;
    }).then((data) {
      response = utf8.decode(data);
      socket.close();
    }).catchError((Object e) {
      response = 'error';
    });
  } else {
    response = 'error';
  }
  return response;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...