FileSystemException: Creation failed, path = 'Directory: '' (OS Error: Read-only file system, errno = 30)


I am receiving an error as Unhandled Exception: FileSystemException: Creation failed, path = 'Directory: '' (OS Error: Read-only file system, errno = 30) when I am trying to save a xlsx file.


class ExportPasswords {
  static exportUserEntries(List entries) async {
    final _psd = PasswordDecrypter();
    final _secureStorage = FlutterSecureStorage();

    //creating the xlsx
    var excel = Excel.createExcel();
    var fileBytes =;

    Sheet sheetObject = excel['pssswd_export'];
    CellStyle cellStyle = CellStyle(
        backgroundColorHex: "#1AFF1A",
        fontFamily: getFontFamily(FontFamily.Calibri));
    cellStyle.underline = Underline.Single;

    for (var entry in entries) {
      final _username = entry['data']['username'];
      final _name = entry['data']['name'];
      final _url = entry['data']['url'];
      final _hashedPassword = entry['data']['password'];
      final _randForKeyToStore = entry['data']['randForKeyToStore'];
      final _randForIV = entry['data']['randForIV'];
      final _masterPassword = await 'masterPassword');

      final _decryptedEntryPassword = await _psd.getDecryptedPassword(
          _hashedPassword, _randForKeyToStore, _randForIV, _masterPassword);

      sheetObject.appendRow([_name, _username, _decryptedEntryPassword, _url]);
    PermissionStatus permissionResult =
        await SimplePermissions.requestPermission(
    if (permissionResult == PermissionStatus.authorized) {
      Directory directory = await getApplicationDocumentsDirectory();
      // print(directory);
      new Directory(directory.path + '/').create(recursive: true).then((dir) {
          ..createSync(recursive: true)

I have given the permission of WRITE_EXTERNAL_STORAGE.

I/SimplePermission( 7685): Requesting permission : android.permission.WRITE_EXTERNAL_STORAGE
I/SimplePermission( 7685): Requesting permission status : 3

In the error it is displayed as Directory : '', but when I am printing the directory value it is showing the path

I/flutter ( 7685): Directory: '/data/user/0/com.palsoham.pssswd.pssswd/app_flutter/'


Please try changing your path in File function from '$dir/pssswd_export' to dir.path + /pssswd_export'.

Answered By – Shahzad Umar Baig

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published