Questions tagged [dart-io]

dart:io allows you to work with files, directories, sockets, processes, HTTP servers and clients, and more

dart:io library is used for Dart server applications, which run on a stand-alone Dart VM from the command line. This library does not work in browser based applications.

This library allows you to work with files, directories, sockets, processes, HTTP servers and clients, and more.

191 questions
1
vote
1 answer

Why does the File class return an object of type '_File' instead of 'File' in Dart/Flutter?

There isn't much else to be said. I created a blank project with no dependencies to test this. Code to copy if you want to run it yourself: import 'dart:io'; void main() { File testFile = File('test'); print('testFile: $testFile'); …
Nathan Tew
  • 432
  • 1
  • 5
  • 21
1
vote
1 answer

Flutter - Unhandled Exception: HttpException: Unexpected response (unsolicited response without request)

I'm having an issue while making an HTTP post request in order send the data to My SQL via php as an API. http and dio both throws same error. I have a php file register_user.php file which connects db and execute insert query. I tested this file…
Shashank Gb
  • 902
  • 1
  • 6
  • 14
1
vote
0 answers

dart io websocket done not called when client disconnects

I am trying to detect when a client has disconnected from the server. I thought that this was the correct way of doing it, but "someone disconnected" is never printed to the console. import 'dart:io'; class VersusServer { Future run() async…
Leonardo da Silva
  • 1,285
  • 2
  • 10
  • 25
1
vote
1 answer

Token Post Request With Flutter dart:io Invalid

I'm doing a post request to an ASP.Net Web API to acquire a token. I am able to do this successfully with the dart HTTP package as follow: Uri address = Uri.parse('https://myaddress:myport/token'); var response = await http.post( address, …
Elmer
  • 384
  • 5
  • 19
1
vote
1 answer

OS Error: No such file or directory, errno = 2, Unhandled Exception: FileSystemException

E/flutter (13503): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException: Cannot open file, path = 'lib/certs/ca.pem' (OS Error: No such file or directory, errno = 2) SecurityContext clientContext = new…
Arnab
  • 11
  • 2
  • 6
1
vote
1 answer

Flutter Directory.systemTemp is not working in the release apk

I'm trying to capture an image from camera and save it in cache(i.e., Directory.systemTemp available from dart.io package). It is working fine in debug mode. But when I build the release apk and install, it is not working. This is the code: import…
Prasanth Kanna
  • 1,961
  • 4
  • 18
  • 25
1
vote
2 answers

Dart: Get POST parameters on server side

I send some data from client side using POST request var value = new Map(); value["param1"] = 'value1'; value["param2"] = 'value2'; value["param3"] = 'value3'; HttpRequest.postFormData('http://localhost:8080/', value); and try to…
user5384930
1
vote
1 answer

Cancel stdin subscription in combination with LineSplitter

I use LineSplitter as a command line interface where every line is a command: import "dart:io"; import 'dart:convert'; void main() { var sub; sub = stdin.transform(UTF8.decoder).transform(new LineSplitter()).listen((l) { if (l == "e") { …
Fox32
  • 13,126
  • 9
  • 50
  • 71
1
vote
0 answers

Unable to execute Ubuntu bash command with Process.run

I have a simple command I want to execute and process the result back in Dart, but I am failing to do this on my Ubuntu server. On my Windows desktop, I can execute this without problems, but I am not able to create the correct command in…
1
vote
2 answers

How do you set a Dart IO Process to use an existing Stream for its stdin?

I'm creating a Process using Process.start and am a bit stuck with the stdin getter. Ideally, I've got a StreamController set up elsewhere, whose stream of Strings I'd like to pass into stdin. But there aren't too many sophisticated examples for…
Crunchex
  • 307
  • 2
  • 10
1
vote
1 answer

Dart http_server serving index.html but not pulling dependencies

Hi I'm trying to create a web app where you can access files on a system through a web browser. The web app structure looks like this: commander cmdr packages lib cmdr.dart gui packages web assets …
1
vote
1 answer

Serving sample website using dart

I just started learning dart, and what I wanted to do as practice is to serve the default web application with a simple webserver. I store the server at E:\DartProject\server and the web client at E:\DartProject\WebClient. Unfortunately I can't get…
Lukasz
  • 2,257
  • 3
  • 26
  • 44
1
vote
1 answer

Breaking on exception: String expected

When I run my code I get: Breaking on exception: String expected What I am trying to do is connect to my server using a websocket. However, it seems that no matter if my server is online or not the client still crashes. My code: import…
1
vote
2 answers

Rewrite request URI in dart

In node.js one can just adjust the url of a request by doing something like this: app.use(function(req, res, next) { if (req.url.slice(-1) === '/') { req.url = req.url.slice(0, -1); } next(); }); The following fails in dart, as all the…
Chenqua
  • 33
  • 2
1
vote
1 answer

How to write a Dart 'worker' server

I want to write a Dart server that reads from a Firebase queue and sends emails. What is not clear to me is how to write a server that listens for something other than HTTP requests, in my case a Firebase queue like e.g. this project .
kpg
  • 7,644
  • 6
  • 34
  • 67