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
0 answers

Dart How to unit test a simple function

I love the way that you can write clean concise code in Dart, but it appears that Dart is one of those languages that it easy to write but hard to test! For example, given the following fairly simple method, how does one go about unit testing…
richard
  • 2,887
  • 5
  • 26
  • 36
1
vote
1 answer

Parameter type confusing

i am trying to use VirtualDirectory class and find a great example in web. import 'dart:io'; import 'package:http_server/http_server.dart'; main() { HttpServer.bind('127.0.0.1', 8888).then((HttpServer server) { var vd = new…
softshipper
  • 32,463
  • 51
  • 192
  • 400
1
vote
1 answer

dart HTMLrequest default to index.html does not work

I have a simple Dart HTTPServer running which serves requests by virDir.serveRequest(request); which works for the URL 192.168.1.200:8080/index.html but serves a 404 Not Found if I use 192.168.1.200:8080 or 192.168.1.200:8080/. I, probably naively,…
Nate Lockwood
  • 3,325
  • 6
  • 28
  • 34
1
vote
2 answers

Port forward request in Dart multi server // Isolate handler

If I have 4 Dart Server Running and I want to forward requests, how would I do that in Dart? On one hand I want to efficiently react on the requests but also be able to have certain requests handled in a distinct way or have an IP from a city…
Dr. Dama
  • 167
  • 2
  • 5
1
vote
1 answer

Dart streaming performance

Apologies if this question is deemed inappropriate for SO, but I was wondering if any of you know if there's a significant performance difference between streaming futures via asStream and consuming futures normally via then. Would you expect a…
lucperkins
  • 768
  • 1
  • 7
  • 15
1
vote
1 answer

Dart reader.on.loadEnd error

do anyone know what is wrong on this code? FileReader reader = new FileReader(); reader.on.loadEnd.add(fileLoader); Error: Breaking on exception: Class 'Events' has no instance getter 'loadEnd'.
John
  • 2,494
  • 5
  • 21
  • 24
1
vote
1 answer

How can DELETE requests be made with a Dart HttpClient?

If you're using a Dart HttpClient (which provides an HttpClientRequest) to make requests from a server to another server, as far as I can tell the only HTTP methods available are GET and POST (corresponding, respectively, to the post/postUrl and…
lucperkins
  • 768
  • 1
  • 7
  • 15
1
vote
2 answers

Weird behavior of Dart code in Windows

The Dart project I'm working on requires multiple instances print statements without new lines. As I understand that printing without a new line in dart can be achieved via stdout.write("string"); All is fine but when I'm trying to write code…
Rahul De
  • 393
  • 3
  • 14
1
vote
1 answer

How does Dart's bindSecure function find SSL certificates?

So I'm writing a server in Dart and want to enable SSL. The bindSecure function is supposed to accomplish that for me, but I can't seem to figure out how to actually refer to the certificate. Let's say that I write the function like…
lucperkins
  • 768
  • 1
  • 7
  • 15
1
vote
1 answer

Dart basic auth not working (dart:io) (UPDATED to working code)

I'm working with the Harvest API, a pretty standard web service API, and my curl requests are working just fine while my Dart HttpClient requests are not. Here is my curl request (with sensitive information disguised, of course): curl -H…
lucperkins
  • 768
  • 1
  • 7
  • 15
1
vote
1 answer

Secure and easy transfer of MySql data from server to client

I have a piece of Dart in my server-side app and I have no idea how to transform the map delivered by MySql into a JSON-type structure, to send these data to the client. Secure: no way of Sql-injection; easy: only a few line of code to convert data,…
Martin
  • 1,430
  • 10
  • 19
1
vote
0 answers

How to upload file using FileUploadInputElement and HttpRequest.requestCrossOrigin()

I have a FileUploadInputElement in my dart code and I want to upload it by POST after button click. Can I sent files via HttpRequest.requestCrossOrigin()? I don't want to use form because it cause my page refresh. ButtonElement…
Roger Chan
  • 1,293
  • 2
  • 11
  • 24
1
vote
1 answer

Dart WebSocket not triggering onOpen or onMessage events?

I have the following client-side code: import 'dart:html'; import 'dart:async'; void main() { WebSocket ws = new WebSocket('ws://127.0.0.1:4949'); ws.onOpen.listen((_) => print('open')); ws.onMessage.listen((MessageEvent e) =>…
Nawaf Alsulami
  • 699
  • 1
  • 8
  • 15
1
vote
2 answers

Monitor and restart Dart process on server

My lightweight dart:io based web server pretty much looks like this: import 'dart:io'; void main() { HttpServer.bind(InternetAddress.ANY_IP_V4, 80).then((server) { server.listen((HttpRequest request) { // ... do stuff... …
Max
  • 9,220
  • 10
  • 51
  • 83
1
vote
1 answer

Memoryleak due to File.openRead and Streamhandling?

I am trapping into a memory leak. I wrote following sample, which increases memory usage continuously: import 'dart:io'; import 'dart:async'; import 'dart:utf'; Future>> readFile2Stream(String path){ File f = new File(path); …
Alex R.
  • 205
  • 1
  • 10