Questions tagged [dart-io]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
54 views

Flutter Http high CPU usage

I tried to send a GET request: Future<void> testHttp() async { final response = await http.Request("GET", Uri.parse(url)).send(); print('testHttp response:${response.statusCode} ');...
czw299's user avatar
  • 48
0 votes
1 answer
37 views

Unable to find file at path with File() object

Creating this file object yields an error: var file = await File('./assets/smslant.flf').readAsString(); //PathNotFoundException (PathNotFoundException: Cannot open file, path = './assets/smslant.flf' ...
bnorum's user avatar
  • 3
0 votes
1 answer
36 views

How can I display an image from Image_picker and dart:io?

I'm currently working on a program where the user would be able to select an image to analyze the text in the image and keep getting the following error while trying to get display the selected image ...
Jana's user avatar
  • 1
0 votes
0 answers
20 views

Issues where I can build app bundle for a simple socket connection app but works on certain android devices

I am working on a simple TCP socket application (through flutter on VS) that is acting as a remote control to a Server. The issue is that the app seems to work on certain android devices. I have a ...
Donovan's user avatar
0 votes
0 answers
39 views

Flutter: Create list of directories with StreamBuilder

I want to create a widget that lists all of the sub directories in a given directory. I have elected to use StreamBuilder to achieve this, here is my app: import 'dart:io'; import 'package:flutter/...
Peter's user avatar
  • 2,947
1 vote
1 answer
137 views

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. ...
JasonTS's user avatar
  • 2,549
0 votes
1 answer
87 views

Dart readAsStringSync not reading lines containing a special character (a dot/full stop)

I am writing a data export/import feature in my application. The output is written as text to a csv file and this appears to be working ok, but the data import is skipping some of the exported lines (...
Twelve1110's user avatar
0 votes
0 answers
75 views

The dart server was terminated when the server is trying to upload files (images) on production host

I am using Ubuntu 20.04 (LTS) x64, NGINX, memory 1 GB, Dart SDK version: 2.19.4 (stable) , and Dart server. I run this dart server in the console with: pm2 start dart --name dart_server -- run ...
Sittiphan Sittisak's user avatar
2 votes
1 answer
152 views

How to build a "Recent files" list?

I'm struggling to find a solution to build a widget that displays "Recent Files". To find the files I have the following Future<List<File>> findFiles(String prefix) async { ...
Icaroto's user avatar
  • 178
0 votes
0 answers
31 views

Can’t open excel file on macos through dart

import 'dart:convert'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:excel/excel.dart'; import 'package:http/http.dart' as http; void main() { runApp(ExcelFirebase()); } ...
krrish-a07's user avatar
0 votes
0 answers
166 views

How to modify a single line in a large file?

I have a large .csv file where I need to edit a single value. Is there a way to do that without writing the entire file again? I know that I can read a file line-by-line like this: await for (var ...
Smofe's user avatar
  • 81
1 vote
0 answers
1k views

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 ...
DavidCZ2051's user avatar
0 votes
1 answer
21 views

building platform specific UI (Android &Ios ) error : ,'Widget', is a potentially non-nullable type

Widget getPicker() { if (Platform.isAndroid) { getDropdownButton(); } else if (Platform.isIOS) { getCupertinoPicker(); } } error: The body might complete normally, causing 'null' to be ...
Midhun Ap's user avatar
2 votes
1 answer
1k views

Flutter: dart:io making a socket connection without using SSL (TLS) Certification

I am building a flutter project where I want to make GET requests to a .onion tor address (REST API). I found a good library: (https://pub.dev/packages/utopic_tor_onion_proxy), that allows you to do ...
Rednas07's user avatar
0 votes
2 answers
459 views

Flutter - android: Exception when convert large file (more than 1GB) to byte

I'm using dart:io to convert file to bytes. with image and short video it's work. but with large file (more than 1GB) i got error E/flutter (16030): [ERROR:flutter/shell/common/shell.cc(93)] Dart ...
anhdhq's user avatar
  • 35
1 vote
1 answer
672 views

dart.io is not supported for web, and universal.io's File doesn't work when assigning arguments

I am making a website and would like files to be uploaded to Firebase Cloud Storage. The issue is, FirebaseStorage.instance.ref().child().putfile() takes in a File, which is from dart.io (apparently ...
BTB's user avatar
  • 23
0 votes
0 answers
23 views

How to check if FileSystemEntity is a Directory [duplicate]

Problem I get the FileSystemEntity list and want to select only Directories from it. So I create a new list and remove all entity types from it except Directory. However, the list just happens to be ...
L3odr0id's user avatar
  • 170
2 votes
1 answer
485 views

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....
ANSAN LEE's user avatar
0 votes
0 answers
119 views

How to delete one directory and replace it with another one for web?

I've replaced one package with another: dart:io on universal_io. And this showed me an error. : Error: A value of type 'Directory/*1*/' can't be assigned to a variable of type 'Directory/*2*/'. lib/…/...
rays7c's user avatar
  • 5
0 votes
1 answer
855 views

final imageFile = await File(path); doesn't create a file

I am using the camera to take a picture and save the picture on phones memory to later send it to AWS. I can take a picture and the path for the picture is there, but I am failing to create a file ...
anar's user avatar
  • 11
4 votes
0 answers
541 views

Flutter: using library universal_io/io.dart when others libs based on dart:io

I want port my app to webapp, but I can't run my app as webapp. Why? Because another libs based on dart:io, not universal_io. Terminal output: lib/services/my_local_storage.dart:134:36: Error: The ...
sosnus's user avatar
  • 1,028
3 votes
0 answers
433 views

Testing stdout and stdin of a Dart console app

I have this simple file: class Console { const Console(); void run() { stdout ..writeln('Choose:\n') ..writeln(' 1) A') ..writeln(' 2) B\n') final input = stdin....
Alberto Miola's user avatar
1 vote
1 answer
613 views

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('...
Nathan Tew's user avatar
0 votes
0 answers
3k views

failing to get response from http.post [http: 499]

I want to build a payment page with the use of a payment page provider. I therefore created a class which builds with a futureBuilder the needed Widgets. From an API I want to receive an URL which I ...
Yves Boutellier's user avatar
0 votes
1 answer
332 views

Uploading pdf generated in flutter web to S3

I am using the pdf 3.6.0 library from pub.dev to generate a pdf in flutter web. When I save the document using doc.save(), I get a Future<Uint8List>. I want to upload this file to S3 For android/...
RIP71DE's user avatar
  • 51
3 votes
0 answers
714 views

Process run / start behaves differently in 'flutter run' and directly running a built app

I'm using Process.run() / Process.start() to open tensorboard in my flutter app on macos. A weird problem is everything goes well when I directly run the flutter app on the connected device (by using ...
EchoShao's user avatar
2 votes
0 answers
224 views

Platform.isIOS not workin on real iOS device

I made a login with Apple on my login screen, and I made an if statement to check if the platform is iOS to show it in iOS devices. The problem is when I run the app on the iOS simulator the button ...
Mhmd Zawi's user avatar
  • 167
0 votes
1 answer
1k views

Flutter dart:io problem with reading and writing file

I'm trying to read data from TXT file but somthing goes wrong. There is a code import 'dart:async' import 'dart:io'; void main(){ File('file.txt').readAsString().then((String contents){ print(...
GDTyka's user avatar
  • 492
2 votes
1 answer
495 views

How to read file from HTTPRequest on a dart:io server

I am trying to create a server to run locally for my application to upload some files while debugging. It is very simple and the full source code is: import 'dart:io'; void main(List<String> ...
Leonardo da Silva's user avatar
2 votes
0 answers
80 views

Dart takes too much RAM while generating random numbers and appending them into a file

I am doing a project that involves generating 1 billion random 0/1 numbers and storing them in a file. This is my code: import 'dart:io'; import 'dart:math'; final int COUNT = 1000000000; final ...
Power_tile's user avatar
0 votes
1 answer
889 views

How to read txt file as Stream in Flutter

i have school project,we are currently doing voice controlled kiosk and the navigation through app will be with voice commands,im doing the application part but im having hard times with integrating ...
Oğuzhan Bagirci's user avatar
1 vote
1 answer
887 views

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 ...
Shashank Gb's user avatar
0 votes
1 answer
1k views

Dart Image to File in local storage

I'm using the Image class from the package image. I have to download a image from internet and save it in my local storage. Then modify this image and save the changes. I have done the first 2 steps, ...
Jorge Luis's user avatar
0 votes
0 answers
293 views

WebSocket connection from Dart/Flutter to Google Cloud Run fails

did anyone use WebSocket connections between a Flutter/Dart client and a server running on Google Cloud Run successfully? Exactly this combination fails for me. The client works with the same server ...
Thomas's user avatar
  • 1
0 votes
1 answer
637 views

Dart Reading Bytes from File and Converting to Double

In Dart/Flutter, I'm trying to read bytes from a data file (2 bytes per value; on a mobile device) and convert to a double. I have the below code: fileToData(File filename) { var bytes = filename....
maxwell79's user avatar
  • 123
-1 votes
1 answer
1k views

How i can convert to double .dart

I have problem in this code, this code can not be executed. Here is the code: import 'dart:io'; main() { print("CALCULATOR"); stdout.write("Number a: "); double a = double....
Kisah Tegar's user avatar
-1 votes
1 answer
491 views

Open file with File() from dart:io

I have a flutter application with a folder certs/ inside the assets' folder like this: certs/ with a cert.pem file inside. I already added the file to the pubspec.yaml: assets: - assets/images/ ...
AFortunato's user avatar
0 votes
2 answers
2k views

Flutter Web: Converting dart:io File to dart:html File

Is there a way to convert dart:io File object to dart:html File? I tried html.File file = dartFile as html.File and it isn't working
Henzelix's user avatar
0 votes
1 answer
368 views

How to take stdin input and break in whitespace in dart?

I want to take 5 inputs like 1 2 3 4 5 using a for loop that runs 5 times. stdin.readLineSync() takes the whitespace as an input and continues until I press ENTER but I want it to separate by ...
Kedar Karki's user avatar
0 votes
1 answer
121 views

Map json from server answer in flutter app

I have a webserver, that always returns a String in this json format: {"status":100,"content":[{"version":"2.2.2"}]} I want my flutter app to map this json to a ...
Salatgurke's user avatar
  • 1,734
0 votes
1 answer
916 views

How to set limit for max connection for single client in Dart http_server?

I have created a simple flutter app to serve my phone directory (Index of /) to share my files with the PC. (I used IDM (Internet Download Manager) to download file) it works fine on small files, but ...
SKJ's user avatar
  • 247
1 vote
0 answers
160 views

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 '...
Leonardo da Silva's user avatar
4 votes
0 answers
1k views

Operations on File object never finishing during unit tests with Flutter

I'm writing unit tests for my Flutter app and I'm having some trouble when reading a json file. I have some json files that are used by my api mock class. Whenever I call a method on the File object, ...
otavio1992's user avatar
9 votes
1 answer
2k views

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
THE_BLESSED_MEDIUM's user avatar
2 votes
0 answers
244 views

Dart/Flutter - HttpServer how to update image with websocket?

I am streaming my display to webserver. My current code is very basic and I don't know exactly how websockets work. Right now the user have to refresh the page to get a new image. I would like to ...
jeff's user avatar
  • 1,189
2 votes
2 answers
685 views

How can I set user-agent in IOWebSocketChannel?

I work with IOWebSocketChannel and I don't have access to Webscoket inside it in order to change the user-agent. how can I achieve that and set user agent for IOWebSocketChannel?
Hamed's user avatar
  • 6,580
9 votes
2 answers
3k views

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....
Suragch's user avatar
  • 491k
1 vote
1 answer
895 views

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'); ...
Elmer's user avatar
  • 384
-2 votes
1 answer
2k views

How to take input in an Array in Dart?

I need to ask the user to input any quantity of space/comma-separated integers and add them to an array to then bubble sort them. I only need help with taking an input in an array. I'm losing brain ...
Timur Monasypov's user avatar
5 votes
3 answers
2k views

How to write a map to a YAML file in Dart

I have a map of key value pairs in Dart. I want to convert it to YAML and write into a file. I tried using YAML package from dart library but it only provides methods to load YAML data from a file. ...
Birju Vachhani's user avatar