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

HTTP3 Client for flutter

Is There a HTTP3 client for dart? There is Flupke in Java, Aioqic in python but I didn't find one for dart as well as flutter
9
votes
1 answer

Using Dart, how to properly return an HttpResponse using Future's

I am attempting to create a very simple http server that does one thing. Upon receiving an HttpRequest, it runs a query on the local database server, and returns a string based on that query. I am learning Dart, and I am having trouble grasping…
jabgibson
  • 416
  • 4
  • 14
8
votes
2 answers

dart:io sync vs async file operations

There are a number of sync and async operations for files in dart:io: file.deleteSync() and file.delete() file.readAsStringSync() and file.readAsString() file.writeAsBytesSync(bytes) and file.writeAsBytes(bytes) and many, many more. What are the…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
8
votes
3 answers

How can I upload a PDF using Dart's HttpClient?

I need to post a PDF file to a remote REST API, and I can't for the life of me figure it out. No matter what I do, the server responds that I have not yet associated an object with the file parameter. Let's say that I have a PDF called test.pdf.…
lucperkins
  • 768
  • 1
  • 7
  • 15
8
votes
1 answer

Dart Stream's listen() not calling onDone

I have a stream with a transformer that fuses the UTF8.decoder to the LineSplitter. It works great but never calls the function specified in the onDone parameter. import 'dart:async'; import 'dart:io'; import 'dart:convert'; void main(List
Nathaniel Johnson
  • 4,731
  • 1
  • 42
  • 69
8
votes
2 answers

Dart UDP client/server

I've been trying to implement a udp client by using the RawDatagramSocket but I'm kind of stuck. I can neither send or receive any data. It's a pretty new feature in Dart as far as I know and I can't find any examples except for tcp. Also, I don't…
Joachim Birche
  • 721
  • 1
  • 6
  • 7
8
votes
2 answers

How to catch SIGINT for the current in Dart?

How can Ctrl+C or SIGINT be caught in a Dart program for the current process? Something similar to this for Node: process.on('SIGINT', function() { // do stuff });
conradkleinespel
  • 6,560
  • 10
  • 51
  • 87
7
votes
2 answers

Flutter, dart:io - convert Uint8List (from websocket) to a jpeg file I can draw

I've written a simple nodejs ws websocket server that is serving a binary jpeg file when a client connects as follows: import WebSocket = require("ws"); console.log("Websocket is starting..."); // Setup websocket const wss = new WebSocket.Server({…
DrZaphod
  • 502
  • 1
  • 5
  • 18
7
votes
1 answer

How to set the current working directory in Dart?

In a dart console application, how do I set the current working directory?
Kasper
  • 12,594
  • 12
  • 41
  • 63
7
votes
3 answers

How to get the file if I know the root directory and relative path?

In Dart, if I know the root directory and the relative path of a file, how to create a file instance for it? Directory root = new Directory("/root"); String relativePath = "logs/users.log"; How to create a file instance for the users.log? In java,…
Freewind
  • 193,756
  • 157
  • 432
  • 708
6
votes
1 answer

Flutter. File existsSync() always returns false

this is the problem that I'm facing right now. I have a folder named 'assets' and inside that folder I have an image named 'no_icon.png'. I have added this to the pubspec.yaml like this: flutter: assets: - assets/teamShields/ -…
Isaac
  • 1,436
  • 2
  • 15
  • 29
6
votes
1 answer

Writing to a file through a loop in Dart

I am trying to write a series of Strings into a file, Letters.txt. import "dart:io"; main() { List letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"]; File file = new File("Letters.txt"); for (int i = 0; i < 10; i++) { …
richalot
  • 4,491
  • 7
  • 24
  • 27
6
votes
1 answer

How to create/add middleware that adds default headers to each request

How can I add middleware to the shelf pipeline that adds default HTTP headers to each request?
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
6
votes
1 answer

Clearing the terminal screen in a command-line Dart app

This one don't work (on Windows in a Cmd-Box): import 'dart:io'; void main() { print("Hello, World!"); Process.start('cls', [], runInShell: true).then((process) { stdout.addStream(process.stdout); …
Eugen
  • 113
  • 2
  • 7
6
votes
1 answer

How to use Dart http_server:VirtualDirectory

I have been using the dart:route api for serving static files but I noticed that there is a core library called http_server that contains helper classes and functions for dart:io HttpServer. Of particular interest to me is the class…
Nathaniel Johnson
  • 4,731
  • 1
  • 42
  • 69
1
2
3
12 13