kineapps / flutter_archive

Flutter plugin for creating and extracting ZIP files.
https://pub.dev/packages/flutter_archive
BSD 3-Clause "New" or "Revised" License
57 stars 43 forks source link

"Something went wrong" but also "File Successfully Saved {##}" #37

Closed UNIcodeX closed 3 years ago

UNIcodeX commented 3 years ago

I get the following error when running the attached code.

D/FileSaver(19385): Save as Method Called
D/Dialog Activity(19385): Opening File Manager
D/Dialog Activity(19385): Starting file operation
D/Dialog Activity(19385): Trying to save file
D/Dialog Activity(19385): Saving file
D/Dialog Activity(19385): Something went wrong
I/flutter (19385): File Successfully Saved 30
W/System  (19385): A resource failed to call close.
void export() async {
  // SETTINGS BOX
  Map mapSettingsData = {};
  Box boxSettingsData = Hive.box(boxSettings);
  for (var key in boxSettingsData.keys) {
    mapSettingsData[key] = boxSettingsData.get(key);
  }
  debug("SETTINGS:\n" + prettyJson(mapSettingsData));

  // WRITE THE FILES
  final _appDirPath = await appDirPath;
  final fileSettings = File("$_appDirPath/settings.json");

  if (isMobile) {
    await Permission.storage.request();
    var status = await Permission.storage.status;
    if (status.isDenied) {
      await Permission.storage.request();
    }
  }

  TextEditingController fileSaveTextController = TextEditingController();

  final fileSettingsAsBytes = fileSettings.readAsBytesSync();
  final fs = FileSaver();
  await fs.saveAs(
      fileSaveTextController.text == ""
          ? "app_name"
          : fileSaveTextController.text,
      fileSettingsAsBytes,
      "txt",
      MimeType.TEXT);
}
kinex commented 3 years ago

I don't see there anything related to this plugin? Wrong repo?

UNIcodeX commented 3 years ago

oh crap... that's embarrasing. I must have had this up in a tab next to the other project. Thanks. 🤦🏽

kinex commented 3 years ago

No problem, it happens 😄