0

I've been struggling to create files with Flutter/dart. Here's my code:

import 'dart:convert';
import 'dart:io';

class FileManager {
  createFile() {
    File('mycol.json').create();
  }
}

I get the following error when executing: enter image description here

Anything I'm doing wrong?

Icaroto
  • 142
  • 10
  • do your app has sufficient permission to create files ? It doesn't seem ! – OMi Shah Nov 10 '22 at 13:52
  • is that something I need to configure in my app? I'm running in the emulator, haven't change any default configuration – Icaroto Nov 10 '22 at 13:53
  • Does this answer your question? [Flutter Unable to create directory (OS Error: Read-only file system)](https://stackoverflow.com/questions/51607002/flutter-unable-to-create-directory-os-error-read-only-file-system) – OMi Shah Nov 10 '22 at 13:53
  • Also, duplicate: https://stackoverflow.com/questions/50892268/flutter-permission-denied-writing-file – OMi Shah Nov 10 '22 at 13:53
  • yes, your app needs sufficient read/write permission to create files on storage. – OMi Shah Nov 10 '22 at 13:55
  • using path_provider I don't get the error anymore! I'm guessing I can't see the file in the project because it's inside the device, correct? – Icaroto Nov 10 '22 at 14:15
  • yes, app's private directory. @Icaroto. – OMi Shah Nov 10 '22 at 14:19
  • 1
    thanks for the links and insight @OMiShah! – Icaroto Nov 10 '22 at 14:28

0 Answers0