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
2
votes
1 answer

Why dart.io and the like can only be used in command line apps?

I want to use libvirt api from dart program. Here is the doc https://www.dartlang.org/articles/native-extensions-for-standalone-dart-vm/. But i find it's only usable in dart command line app, so is dart.io. I am not familiar with web app, i wonder…
apporc
  • 870
  • 3
  • 11
  • 23
2
votes
3 answers

How do I fetch URL from a Dart server (dart:io)?

While fetching a URL in on the client (dart:html) is straightforward, the server side (dart:io) doesn't have the handy getString method. How do I simply load a URL document as a String?
filiph
  • 2,673
  • 2
  • 26
  • 33
2
votes
1 answer

HTTPRequest.request with sendData, can't seem to get this to work

I'm trying to wrap my head around Dart, and in doing so got stumped with adding some data to an HTTPRequest. I need to send a parameter with this request, so I figured the "sendData" variable would probably help me do that. Documentation is sparse…
mrand01
  • 261
  • 2
  • 9
2
votes
1 answer

How do I apply a filter to every request, using Dart and the route package?

I am writing server-side Dart, and I'm using the http_server and route packages. I'd like to run a filter for every single request. In this particular case, I want to add CORS headers. Here's the code I have so far: new Router(server) …
Seth Ladd
  • 112,095
  • 66
  • 196
  • 279
2
votes
1 answer

Does Dart support the W3C File API standard?

I wrote a Dart web app that compiles to Javascript (dart2js), which I package in an APK (PhoneGap) and run as an Android app. I want my app to backup and restore its data from the local file system. W3C has a File API standard for file IO within a…
devdanke
  • 1,309
  • 15
  • 27
2
votes
2 answers

How to replace ZLibDeflater with ZLibEncoder

I'm using the ZLibDeflater to compress a file, by reading it as a stream and transforming it: new File(filePath) .openRead() .transform(new ZLibDeflater()) .pipe(new File(gzipPath).openWrite()) .then(...); As the ZLibDeflater is now…
Fox32
  • 13,126
  • 9
  • 50
  • 71
2
votes
1 answer

Dart Read support for binary files

there exist some sample code for an Http Server in the Dart:io section. Now I will distribute images with this server. To achieve this, I read the requested image file and send its content to the client via request.response.write(). The problem is…
Alex R.
  • 205
  • 1
  • 10
2
votes
1 answer

Simple command-line app I/O in Dart

Is there a way of taking single character (integer) keyboard inputs from the user and storing them to a variable in a Dart command-line app? I've tried something like: Stream cmdLine = stdin .transform(new StringDecoder()) .transform(new…
Instinct
  • 349
  • 1
  • 3
  • 10
2
votes
2 answers

TCP Socket Server that listens to a port and PUSHes data with Web Sockets

I saw there is a new version of dart:io. How do I create a socket server with the new v2 dart:IO that listens to a port for new data and pushes the received data via Web Sockets to its subscribed clients? I have a java and a c# desktop application…
Gero
  • 12,993
  • 25
  • 65
  • 106
2
votes
2 answers

Reading multiple inputs from Dart Console

I want to read different data from the console in a Dart server application, like: forename : user inputs and enters lastname : user inputs and enters age : user inputs and enters The following code works, but for 1 input item only: var…
2
votes
3 answers

Reading static files under a library in Dart?

I am writing a library in Dart and I have static files under the library folder. I want to be able to read those files, but I'm not sure how to retrieve the path to it... there is not __FILE__ or $0 like in some other languages. Update: It seems…
Tower
  • 98,741
  • 129
  • 357
  • 507
2
votes
1 answer

Reading File in Dart

I am trying to read a file (made a simple .txt file on my desktop for that purpose) from machine using Dart on Dartium browser. I have an input field, added a listener to it and here is how it looks: void _onFileSelect(event) { dom.File file =…
Pijusn
  • 11,025
  • 7
  • 57
  • 76
1
vote
1 answer

How to add user input in dart test?

I'm new to dart and trying out testing. My first programm is a command line tool that takes user input. How can I simulate that during testing? My function lets the user choose an item out of a list. I'd like to write tests if the function…
JasonTS
  • 2,479
  • 4
  • 32
  • 48
1
vote
0 answers

Flutter Process.run() with runInShell: true runs the command in shell but when compiled to exe opens a new window

I have a function that uses the Windows ping command: ProcessResult process = await Process.run( 'ping', ['-n', '1', '-l', '1', '-w', '100', host.name], runInShell: true, ); When I run it in Visual Studio Code it works normally. But When I…
1
vote
1 answer

Doesn't work stdout.write Method but can work stdout.writeln

import 'dart:io' void main(){ stdout.write("abc");} that code doesn't worked but void main(){ stdout.writeln("abc");} was work!! output is "abc" and void main(){ stdout.write("abc"); stdout.writeln("def");} out put is "abcdef" I can't understand…
ANSAN LEE
  • 13
  • 2