GithubHelp home page GithubHelp logo

incrediblezayed / file_saver Goto Github PK

View Code? Open in Web Editor NEW
75.0 75.0 93.0 807 KB

A simple flutter plugin for saving files in all platforms

Home Page: https://pub.dev/packages/file_saver

License: BSD 3-Clause "New" or "Revised" License

Kotlin 17.72% Swift 6.46% Objective-C 0.53% Dart 27.59% CMake 13.37% C++ 25.64% C 2.41% HTML 2.97% Ruby 3.31%

file_saver's Introduction

Hi šŸ‘‹, I'm Hassan

A passionate full-stack developer

incrediblezayed

Langauges and Tools

Current Streak

Top Langs

šŸŒ Socials

Instagram LinkedIn Twitter

  • šŸ”­ Iā€™m currently working on a closed source šŸ¤« project right now But will soon start some open source stuff

  • šŸŒ± Iā€™m currently learning ReactJS

  • šŸ‘Æ Iā€™m looking to collaborate on Flutter

  • šŸ¤ Iā€™m looking for help with since my hands are filled with alot of stuff File Saver, a flutter plugin for saving files

  • šŸ“ I regularly write articles on Coming soon...

  • šŸ’¬ Ask me about Flutter and everything else, because I'm open to share and accept knowledge of any kind

  • šŸ“« How to reach me? [email protected]

  • āš” Fun fact I'm lost in my own world of programs

file_saver's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

file_saver's Issues

Passing bytes parameter not working as expected

Hi guys! Passing the bytes parameter still gets the assertion

String? savedPath = await FileSaver.instance.saveAs(
name: "fileNameXXX.file",
bytes: fileContent,
ext: "file",
mimeType: MimeType.other);

filePath != null || link != null || file != null
"Either filePath or link or file must be provided"

Wrong or missing file extension when calling saveAs()

Whenever you open the .saveAs() and try to save a file with a custom extension, it will still save as a .json file.
await FileSaver.instance.saveAs(fileName, data, 'custom123', MimeType.JSON)

When you set the MimeType to OTHER, it saves without an extension.
await FileSaver.instance.saveAs(fileName, data, 'custom123', MimeType.OTHER)

I've only tried this code on Android.

saveFile produces empty file after upgrade to 0.2.0 (Web)

After I upgraded from v0.1.1 to v0.2.0 the resulting file on web release is empty.

Code before:

final Uint8List data = Uint8List.fromList(csv.codeUnits);

MimeType type = MimeType.CSV;

await FileSaver.instance.saveFile(
  "inventory.csv",
  data,
  "csv",
  mimeType: type);

After upgrade:

final Uint8List data = Uint8List.fromList(csv.codeUnits);

MimeType type = MimeType.csv;

await FileSaver.instance.saveFile(
  name: "inventory.csv",
  bytes: data,
  ext: "csv",
  mimeType: type);

Flutter/Dart versions are 3.7.8/2.19.5

NSInternalInconsistencyException thrown from saveAs on macOS

When using the aforementioned code on macOS to saveAs a file, a NSInternalInconsistencyException is thrown.

Implementation

  Future<void> _downloadAndSaveFile() async {
    final data = await http.get(
      Uri.parse(attachment.url),
    );
    final extension = p.extension(attachment.url).replaceAll('.', '');
    await FileSaver.instance
        .saveAs(attachment.title, data.bodyBytes, extension, MimeType.ZIP);
  }

Exception

2022-03-08 03:46:08.880 Superlist[27755:4148432] -[NSSavePanel observeValueForKeyPath:ofObject:change:context:] caught non-fatal NSInternalInconsistencyException 'Unsupported value for standard codec' with backtrace (
	0   CoreFoundation                      0x00007fff2080a29b __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff20543d92 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff20833422 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff215f24d2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   FlutterMacOS                        0x000000010c56f188 -[FlutterStandardWriter writeValue:] + 2024
	5   FlutterMacOS                        0x000000010c56d785 -[FlutterStandardMethodCodec encodeSuccessEnvelope:] + 117
	6   FlutterMacOS                        0x000000010c56b38a __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke_2 + 154
	7   file_saver                          0x000000010b60823d $syXlSgIeyBy_ypSgIegn_TR + 221
	8   file_saver                          0x000000010b605d67 $s10file_saver6DialogC8saveFile33_D4C5CDA81D09C203BAC31A1F4939CEC0LL8byteData3url0A4Name3ext6resultySays5UInt8VG_10Foundation3URLVS2SyypSgctF + 487
	9   file_saver                          0x000000010b605948 $s10file_saver6DialogC010openSaveAsC06params6resultyAA6ParamsV_yypSgctFySo15NSModalResponseacfU_ + 1304
	10  file_saver                          0x000000010b605ae8 $sSo15NSModalResponseaIegy_ABIeyBy_TR + 56
	11  AppKit                              0x00007fff239bbd86 -[NSSavePanel didEndPanelWithReturnCode:] + 76
	12  AppKit                              0x00007fff239bbfda -[NSSavePanel completeModeless:] + 23
	13  AppKit                              0x00007fff239bc2d6 -[NSSavePanel completeWithReturnCode:url:urls:] + 434
	14  AppKit                              0x00007fff239bdf02 -[NSSavePanel observeValueForKeyPath:ofObject:change:context:] + 325
	15  Foundation                          0x00007fff214f3d6c NSKeyValueNotifyObserver + 327
	16  Foundation                          0x00007fff215badd0 NSKeyValueDidChange + 431
	17  Foundation                          0x00007fff2165b71d NSKeyValueDidChangeWithPerThreadPendingNotifications + 146
	18  ViewBridge                          0x00007fff2737c3db __41-[NSViewBridge setObject:forKey:withKVO:]_block_invoke + 360
	19  ViewBridge                          0x00007fff273f6fc5 withHintInProgress + 359
	20  ViewBridge                          0x00007fff273742c2 -[NSViewBridge setObject:forKey:withKVO:] + 641
	21  ViewBridge                          0x00007fff2737541d -[NSViewBridge nonLocalChangeInProgress:block:] + 230
	22  ViewBridge                          0x00007fff273751ab -[NSRemoteViewMarshal exceptionSafeSetRemoteObject:forKey:withReply:] + 264
	23  ViewBridge                          0x00007fff2737505f -[NSRemoteViewMarshal setRemoteObject:forKey:withReply:] + 56
	24  CoreFoundation                      0x00007fff207737bc __invoking___ + 140
	25  CoreFoundation                      0x00007fff2077365d -[NSInvocation invoke] + 305
	26  ViewBridge                          0x00007fff27373169 __deferNSXPCInvocationOntoMainThread_block_invoke + 228
	27  ViewBridge                          0x00007fff27366355 __wrapBlockWithVoucher_block_invoke + 37
	28  ViewBridge                          0x00007fff27366039 __deferBlockOntoMainThread_block_invoke_2 + 352
	29  CoreFoundation                      0x00007fff2078ff12 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	30  CoreFoundation                      0x00007fff2078fdc3 __CFRunLoopDoBlocks + 440
	31  CoreFoundation                      0x00007fff2078f12c __CFRunLoopRun + 2589
	32  CoreFoundation                      0x00007fff2078e04c CFRunLoopRunSpecific + 563
	33  HIToolbox                           0x00007fff289d6a83 RunCurrentEventLoopInMode + 292
	34  HIToolbox                           0x00007fff289d67e5 ReceiveNextEventCommon + 587
	35  HIToolbox                           0x00007fff289d6583 _BlockUntilNextEventMatchingListInModeWithFilter + 70
	36  AppKit                              0x00007fff22f96d72 _DPSNextEvent + 864
	37  AppKit                              0x00007fff22f95545 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1364
	38  AppKit                              0x00007fff22f87869 -[NSApplication run] + 586
	39  Superlist                           0x00000001098833c6 _ZN60_$LT$$LP$$RP$$u20$as$u20$objc..message..MessageArguments$GT$6invoke17h89917d51d20ac9deE + 70
	40  Superlist                           0x000000010989f77c _ZN4objc7message8platform15send_unverified17h8b0033e3d0301f3cE + 92
	41  Superlist                           0x0000000109828f95 _ZN82_$LT$$BP$mut$u20$objc..runtime..Object$u20$as$u20$cocoa..appkit..NSApplication$GT$3run17hbd36f1d89c16f2e5E + 277
	42  Superlist                           0x0000000109712b84 _ZN11nativeshell5shell8platform13platform_impl8run_loop15PlatformRunLoop3run17h8d185366b27b562aE + 52
	43  Superlist                           0x00000001096b93ac _ZN11nativeshell5shell8run_loop7RunLoop3run17h27bdc1687f44095bE + 188
	44  Superlist                           0x0000000109050a53 _ZN16superlist_common3src17superlist_common_17hc76ddfda066bac81E + 4147
	45  Superlist                           0x000000010904f4df _ZN16superlist_common3src16superlist_common17hcb6c84eea42fd749E + 47
	46  Superlist                           0x0000000108ff6908 superlist_main + 328
	47  Superlist                           0x0000000108fd8030 $s9Superlist3AppV4mainyyFZ + 16
	48  Superlist                           0x0000000108fd8099 $s9Superlist3AppV5$mainyyFZ + 9
	49  Superlist                           0x0000000108fd80b4 main + 20
	50  libdyld.dylib                       0x00007fff206b3f3d start + 1
	51  ???                                 0x0000000000000001 0x0 + 1
)

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

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);
}

Error: MissingPluginException(No implementation found for method saveFile on channel file_saver) flutter web

using flutter web

error log

Error: MissingPluginException(No implementation found for method saveFile on channel file_saver)

pub.dev

  file_saver: 
    git:
      url: https://github.com/incrediblezayed/file_saver


flutter doctor

[āˆš] Flutter (Channel stable, 3.7.6, on Microsoft Windows [Version 10.0.22621.1344], locale ko-KR)
[X] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
[āˆš] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[āˆš] Chrome - develop for the web
[āˆš] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.17)
[āˆš] Android Studio (version 2021.2)
[āˆš] Android Studio (version 2022.1)
[āˆš] VS Code (version 1.76.1)
[āˆš] Connected device (4 available)
[āˆš] HTTP Host Availability
  void exportToCsv() async {
    String title = "pluto_grid_export";

    var exported = const Utf8Encoder()
        .convert(pluto_grid_export.PlutoGridExport.exportCSV(stateManager));

    // use file_saver from pub.dev
    await FileSaver.instance
        .saveFile(name: "$title.csv", bytes: exported, ext: ".csv");
  }

exported has data but when save then error

what is problem?

iOS Files recording for more than five minutes will run out of memory

pc 0x000000015be15f80 fp 0x000000016e648058 sp 0x000000016e647fe8 [Unoptimized] _RandomAccessFile@13069316._dispatch@13069316
pc 0x000000015be14984 fp 0x000000016e648118 sp 0x000000016e648068 [Unoptimized] [email protected]
pc 0x000000015be14118 fp 0x000000016e648170 sp 0x000000016e648128 [Unoptimized] [email protected].
pc 0x000000015bdb207c fp 0x000000016e6481e8 sp 0x000000016e648180 [Unoptimized] _rootRunUnary@4048458
pc 0x000000015bdb1e70 fp 0x000000016e648250 sp 0x000000016e6481f8 [Unoptimized] _rootRunUnary@4048458
pc 0x000000015bdb1a04 fp 0x000000016e6482e8 sp 0x000000016e648260 [Unoptimized] [email protected]
pc 0x000000015bdc1878 fp 0x000000016e648338 sp 0x000000016e6482f8 [Unoptimized] [email protected]
pc 0x000000015bdc1488 fp 0x000000016e648398 sp 0x000000016e648348 [Unoptimized] _Future@4048458[email protected]
pc 0x000000015bdc0404 fp 0x000000016e648418 sp 0x000000016e6483a8 [Unoptimized] _Future@4048458._propagateToListeners@4048458
pc 0x000000015bdbec38 fp 0x000000016e648460 sp 0x000000016e648428 [Unoptimized] _Future@4048458._completeWithValue@4048458
pc 0x000000015bdbe900 fp 0x000000016e6484a0 sp 0x000000016e648470 [Unoptimized] _Future@4048458._asyncCompleteWithValue@4048458.
pc 0x000000015a7c09d4 fp 0x000000016e648510 sp 0x000000016e6484b0 [Unoptimized] _rootRun@4048458
pc 0x000000015a7c0638 fp 0x000000016e648570 sp 0x000000016e648520 [Unoptimized] _rootRun@4048458
pc 0x000000015a7bfd3c fp 0x000000016e648600 sp 0x000000016e648580 [Unoptimized] [email protected]
pc 0x000000015bda3684 fp 0x000000016e648670 sp 0x000000016e648610 [Unoptimized] [email protected]
pc 0x000000015bda3540 fp 0x000000016e6486b0 sp 0x000000016e648680 [Unoptimized] [email protected].
pc 0x000000015bda321c fp 0x000000016e6486f8 sp 0x000000016e6486c0 [Unoptimized] _microtaskLoop@4048458
pc 0x000000015bda2da4 fp 0x000000016e648738 sp 0x000000016e648708 [Unoptimized] _startMicrotaskLoop@4048458
pc 0x000000015bda2ca0 fp 0x000000016e648760 sp 0x000000016e648748 [Unoptimized] _startMicrotaskLoop@4048458
pc 0x0000000108482ff4 fp 0x000000016e648830 sp 0x000000016e648770 [Stub] InvokeDartCode

  • thread #40, name = '0f0d6f83-502d-4c7b-abd7-fa208bb7f409.3.ui', stop reason = signal SIGABRT
    frame #0: 0x00000001f2c04b78 libsystem_kernel.dylib__pthread_kill + 8 libsystem_kernel.dylib__pthread_kill:
    -> 0x1f2c04b78 <+8>: b.lo 0x1f2c04b98 ; <+40>
    0x1f2c04b7c <+12>: pacibsp
    0x1f2c04b80 <+16>: stp x29, x30, [sp, #-0x10]!
    0x1f2c04b84 <+20>: mov x29, sp
    Target 0: (Runner) stopped.
    Lost connection to device.

'Save As' does not work on MacOS

The save as function doesnt work on MacOS, save works fine. Tried digging deeper and realised the
await _channel.invokeMethod<String>(_saveAs, args) in _openFileManager doesnt complete or return any value. Cant go any deeper as I do not write swift.

MacOS, Monterey, version 12.6

Weldone on such a great package though, really helpful.

Error on debugging

file_saver: ^0.2.2

Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':file_saver'.
> Could not resolve all artifacts for configuration ':file_saver:classpath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0.
     Required by:
         project :file_saver
      > Cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
          - gradle70JavadocElements
          - gradle70RuntimeElements
          - gradle70SourcesElements
          - gradle71JavadocElements
          - gradle71RuntimeElements
          - gradle71SourcesElements
          - gradle75JavadocElements
          - gradle75RuntimeElements
          - gradle75SourcesElements
          - gradle76JavadocElements
          - gradle76RuntimeElements
          - gradle76SourcesElements
          - javadocElements
          - runtimeElementsWithFixedAttribute
          - sourcesElements
        All of them match the consumer attributes:
          - Variant 'gradle70JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'javadoc' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.plugin.api-version '7.0' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle70RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'library' but wasn't required.
                  - Found org.gradle.jvm.environment 'standard-jvm' but wasn't required.
                  - Found org.gradle.plugin.api-version '7.0' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.jvm.version '11' and found compatible value '8'.
                  - Required org.gradle.libraryelements 'jar' and found compatible value 'jar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle70SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'sources' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.plugin.api-version '7.0' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle71JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'javadoc' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.plugin.api-version '7.1' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle71RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'library' but wasn't required.
                  - Found org.gradle.jvm.environment 'standard-jvm' but wasn't required.
                  - Found org.gradle.plugin.api-version '7.1' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.jvm.version '11' and found compatible value '8'.
                  - Required org.gradle.libraryelements 'jar' and found compatible value 'jar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle71SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'sources' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.plugin.api-version '7.1' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle75JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'javadoc' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.plugin.api-version '7.5' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle75RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'library' but wasn't required.
                  - Found org.gradle.jvm.environment 'standard-jvm' but wasn't required.
                  - Found org.gradle.plugin.api-version '7.5' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.jvm.version '11' and found compatible value '8'.
                  - Required org.gradle.libraryelements 'jar' and found compatible value 'jar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle75SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'sources' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.plugin.api-version '7.5' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle76JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'javadoc' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.plugin.api-version '7.6' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle76RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'library' but wasn't required.
                  - Found org.gradle.jvm.environment 'standard-jvm' but wasn't required.
                  - Found org.gradle.plugin.api-version '7.6' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.jvm.version '11' and found compatible value '8'.
                  - Required org.gradle.libraryelements 'jar' and found compatible value 'jar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'gradle76SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'sources' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.plugin.api-version '7.6' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'javadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'javadoc' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'runtimeElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'library' but wasn't required.
                  - Found org.gradle.jvm.environment 'standard-jvm' but wasn't required.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.jvm.version '11' and found compatible value '8'.
                  - Required org.gradle.libraryelements 'jar' and found compatible value 'jar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'sourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0:
              - Unmatched attributes:
                  - Found org.gradle.category 'documentation' but wasn't required.
                  - Found org.gradle.docstype 'sources' but wasn't required.
                  - Required org.gradle.jvm.version '11' but no value provided.
                  - Required org.gradle.libraryelements 'jar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
              - Compatible attributes:
                  - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
> Failed to notify project evaluation listener.
   > Could not get unknown property 'android' for project ':file_saver' of type org.gradle.api.Project.
   > Could not get unknown property 'android' for project ':file_saver' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Exception: Gradle task assembleDebug failed with exit code 1

macOS type cast exception

On macOS there is error:

type 'Future<Directory?>' is not a subtype of type 'FutureOr<Directory>' in type cast

I guess it is in _getDirectory method:

if (Platform.isMacOS) {
    _path = (await (path.getDownloadsDirectory() as FutureOr<Directory>)).path;
}

Execution failed for task ':file_saver:compileDebugKotlin'.

Launching lib\main_stage.dart on Pixel 4a in debug mode...
lib\main_stage.dart:1
Parameter format not correct -
e: C:\Workspace\flutter.pub-cache\hosted\pub.dartlang.org\file_saver-0.1.0\android\src\main\kotlin\com\one\file_saver\FileSaverPlugin.kt: (30, 25): Smart cast to 'FlutterPlugin.FlutterPluginBinding' is impossible, because 'pluginBinding' is a mutable property that could have been changed by this time
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':file_saver:compileDebugKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
Compilation error. See log for more details

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 3m 12s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

image

file_saver: ^0.1.0 gradle:7.1.0 can not load

A problem occurred configuring project ':file_saver'.

Could not resolve all artifacts for configuration ':file_saver:classpath'.
Could not resolve io.grpc:grpc-api:[1.21.1].
Required by:
project :file_saver > com.android.tools.build:gradle:7.1.0 > io.grpc:grpc-core:1.21.1
> Failed to list versions for io.grpc:grpc-api.
> Unable to load Maven meta-data from https://repo.maven.apache.org/maven2/io/grpc/grpc-api/maven-metadata.xml.
> Could not HEAD 'https://repo.maven.apache.org/maven2/io/grpc/grpc-api/maven-metadata.xml'.
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Could not resolve io.netty:netty-codec-http2:[4.1.34.Final].
Required by:
project :file_saver > com.android.tools.build:gradle:7.1.0 > io.grpc:grpc-netty:1.21.1
> Failed to list versions for io.netty:netty-codec-http2.
> Unable to load Maven meta-data from https://repo.maven.apache.org/maven2/io/netty/netty-codec-http2/maven-metadata.xml.
> Could not HEAD 'https://repo.maven.apache.org/maven2/io/netty/netty-codec-http2/maven-metadata.xml'.
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

https://repo.maven.apache.org/maven2/io/netty/netty-codec-http2/maven-metadata.xml Its certificate has expired

Exception while saving file Reply already submitted

Hi, thanks for this package!

I have 2 functions: one for saving file (export) and another for loading file (import). Loading files is implemented with file_picker library. If I call import many times I have no errors, the same with export. But if I call import and then export (and vise-versa), app crashes (see logs below).

I have zero knowledge of android development, all I can say from logs is that result.success on android side is called twice, probably because of not closed activity (?).

I also tried with flutter_file_dialog for importing, still crashes at file_saver level.

Code samples:

Future<void> _exportSettings() async {
  final exportedSettings = Uint8List.fromList(utf8.encode('{"hello":"world"}'));
  try {
    String response;
    if (kIsWeb) {
      response = await FileSaver.instance.saveFile("config", exportedSettings, "json", mimeType: MimeType.JSON);
    } else {
      response = await FileSaver.instance.saveAs("config.json", exportedSettings, "json", MimeType.JSON);
    }

    print("saved file '$response'");
    return;
  } on Exception catch (e) {
    return print("Failed to save config: ${e.toString()}");
  }
}

Future<void> _importSettings() async {
  try {
    FilePickerResult? result;
    if (kIsWeb) {
      result =
          await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ["json"], withData: true);
    } else {
      result = await FilePicker.platform.pickFiles(type: FileType.any, withData: true);
    }

    if (result == null) {
      print("aborted importing");
      return;
    }

    final fileBytes = result.files.first.bytes;
    final fileString = utf8.decode(fileBytes!.toList());
    final fileName = result.files.first.name;

    print("imported file '$fileName':");
    print(fileString);
    return;
  } on Exception catch (e) {
    return print("Failed to import config file: ${e.toString()}");
  }
}
Crash log when first saving and then loading file
09-03 19:41:15.160 17784 17784 D FileSaver: Dialog was null
09-03 19:41:15.160 17784 17784 D FileSaver: Creating File Dialog Activity
09-03 19:41:15.160 17784 17784 D FileSaver: Save as Method Called
09-03 19:41:15.161 17784 17784 D Dialog Activity: Opening File Manager
09-03 19:41:15.177 17784 17903 I flutter : didChangeAppLifecycleState AppLifecycleState.inactive
09-03 19:41:15.193 17784 17904 D skia    : Shader compilation error
09-03 19:41:15.193 17784 17904 D skia    : ------------------------
09-03 19:41:15.193 17784 17904 D skia    : Errors:
09-03 19:41:15.193 17784 17904 D skia    : 
09-03 19:41:15.312 17784 17821 D EGL_emulation: eglMakeCurrent: 0x75ba3063d9a0: ver 3 1 (tinfo 0x75ba306cb6c0)
09-03 19:41:15.679 17784 17903 I flutter : didChangeAppLifecycleState AppLifecycleState.paused
09-03 19:41:20.658 17784 17784 D Dialog Activity: Starting file operation
09-03 19:41:20.666 17784 17784 D Dialog Activity: Saving file
09-03 19:41:20.668 17784 17903 I flutter : didChangeAppLifecycleState AppLifecycleState.resumed
09-03 19:41:20.688 17784 17784 D Dialog Activity: Something went wrong
09-03 19:41:20.699 17784 17790 I zygote64: Do partial code cache collection, code=61KB, data=59KB
09-03 19:41:20.699 17784 17790 I zygote64: After code cache collection, code=61KB, data=59KB
09-03 19:41:20.699 17784 17790 I zygote64: Increasing code cache capacity to 256KB
09-03 19:41:20.729 17784 17904 D EGL_emulation: eglMakeCurrent: 0x75ba3859b5e0: ver 3 1 (tinfo 0x75ba2d869ec0)
09-03 19:41:20.733 17784 17904 D EGL_emulation: eglMakeCurrent: 0x75ba3859b5e0: ver 3 1 (tinfo 0x75ba2d869ec0)
09-03 19:41:20.740 17784 17821 D EGL_emulation: eglMakeCurrent: 0x75ba3063d9a0: ver 3 1 (tinfo 0x75ba306cb6c0)


09-03 19:41:32.312 17784 17784 D FilePickerDelegate: Selected type */*
09-03 19:41:32.327 17784 17903 I flutter : didChangeAppLifecycleState AppLifecycleState.inactive
09-03 19:41:32.401 17784 17904 D skia    : Shader compilation error
09-03 19:41:32.401 17784 17904 D skia    : ------------------------
09-03 19:41:32.401 17784 17904 D skia    : Errors:
09-03 19:41:32.401 17784 17904 D skia    : 
09-03 19:41:32.463 17784 17904 D skia    : Shader compilation error
09-03 19:41:32.463 17784 17904 D skia    : ------------------------
09-03 19:41:32.463 17784 17904 D skia    : Errors:
09-03 19:41:32.463 17784 17904 D skia    : 
09-03 19:41:32.478 17784 17821 D EGL_emulation: eglMakeCurrent: 0x75ba3063d9a0: ver 3 1 (tinfo 0x75ba306cb6c0)
09-03 19:41:32.834 17784 17903 I flutter : didChangeAppLifecycleState AppLifecycleState.paused
09-03 19:41:44.897 17784 17784 D Dialog Activity: Starting file operation
09-03 19:41:44.897 17784 17948 I FilePickerUtils: Caching from URI: content://com.android.providers.downloads.documents/document/14
09-03 19:41:44.901 17784 17903 I flutter : didChangeAppLifecycleState AppLifecycleState.resumed
09-03 19:41:44.901 17784 17784 D Dialog Activity: Saving file
09-03 19:41:44.909 17784 17784 D Dialog Activity: Error while writing filePermission Denial: writing com.android.providers.downloads.DownloadStorageProvider uri content://com.android.providers.downloads.documents/document/14 from pid=17784, uid=10067 requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission()
09-03 19:41:44.914 17784 17784 D Dialog Activity: Exception while saving fileReply already submitted
09-03 19:41:44.915 17784 17784 D Dialog Activity: Something went wrong
09-03 19:41:44.920 17784 17948 D FilePickerUtils: File loaded and cached at:/data/user/0/com.anywherelan.awl/cache/file_picker/config_awl.json
09-03 19:41:44.921 17784 17948 D FilePickerDelegate: File path:[com.mr.flutter.plugin.filepicker.FileInfo@b84494b]
--------- beginning of crash
09-03 19:41:44.970 17784 17784 E AndroidRuntime: FATAL EXCEPTION: main
09-03 19:41:44.970 17784 17784 E AndroidRuntime: Process: com.anywherelan.awl, PID: 17784
09-03 19:41:44.970 17784 17784 E AndroidRuntime: java.lang.IllegalStateException: Reply already submitted
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:164)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:243)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at com.one.file_saver.Dialog$completeFileOperation$1.invokeSuspend(Dialog.kt:72)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:790)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:99)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6494)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
09-03 19:41:44.970 17784 17784 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Crash log when first loading and then saving file
09-03 19:44:10.620 17966 17966 D FilePickerDelegate: Selected type */*
09-03 19:44:10.628 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.inactive
09-03 19:44:10.677 17966 17987 D skia    : Shader compilation error
09-03 19:44:10.677 17966 17987 D skia    : ------------------------
09-03 19:44:10.677 17966 17987 D skia    : Errors:
09-03 19:44:10.677 17966 17987 D skia    : 
09-03 19:44:10.708 17966 17987 D skia    : Shader compilation error
09-03 19:44:10.708 17966 17987 D skia    : ------------------------
09-03 19:44:10.708 17966 17987 D skia    : Errors:
09-03 19:44:10.708 17966 17987 D skia    : 
09-03 19:44:10.781 17966 17997 D EGL_emulation: eglMakeCurrent: 0x75ba306304a0: ver 3 1 (tinfo 0x75ba306fe5c0)
09-03 19:44:11.133 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.paused
09-03 19:44:14.422 17966 18032 I FilePickerUtils: Caching from URI: content://com.android.providers.downloads.documents/document/32
09-03 19:44:14.430 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.resumed
09-03 19:44:14.441 17966 18032 D FilePickerUtils: File loaded and cached at:/data/user/0/com.anywherelan.awl/cache/file_picker/config_awlddddd.json
09-03 19:44:14.441 17966 18032 D FilePickerDelegate: File path:[com.mr.flutter.plugin.filepicker.FileInfo@5f61b44]
09-03 19:44:14.493 17966 17987 D EGL_emulation: eglMakeCurrent: 0x75ba2d862560: ver 3 1 (tinfo 0x75ba2d990620)
09-03 19:44:14.494 17966 17987 D EGL_emulation: eglMakeCurrent: 0x75ba2d862560: ver 3 1 (tinfo 0x75ba2d990620)


09-03 19:44:21.403 17966 17966 D FileSaver: Dialog was null
09-03 19:44:21.403 17966 17966 D FileSaver: Creating File Dialog Activity
09-03 19:44:21.403 17966 17966 D FileSaver: Save as Method Called
09-03 19:44:21.403 17966 17966 D Dialog Activity: Opening File Manager
09-03 19:44:21.410 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.inactive
09-03 19:44:21.572 17966 17997 D EGL_emulation: eglMakeCurrent: 0x75ba306304a0: ver 3 1 (tinfo 0x75ba306fe5c0)
09-03 19:44:21.902 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.paused
09-03 19:44:28.114 17966 17966 D Dialog Activity: Starting file operation
09-03 19:44:28.120 17966 17966 D Dialog Activity: Saving file
09-03 19:44:28.121 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.resumed
09-03 19:44:28.130 17966 17966 D Dialog Activity: Something went wrong
09-03 19:44:28.161 17966 17987 D EGL_emulation: eglMakeCurrent: 0x75ba2d862560: ver 3 1 (tinfo 0x75ba2d990620)
09-03 19:44:28.163 17966 17987 D EGL_emulation: eglMakeCurrent: 0x75ba2d862560: ver 3 1 (tinfo 0x75ba2d990620)
09-03 19:44:28.180 17966 17997 D EGL_emulation: eglMakeCurrent: 0x75ba306304a0: ver 3 1 (tinfo 0x75ba306fe5c0)
09-03 19:44:29.772 17966 18008 I GoLog   : 2021-09-03 16:44:29  INFO    dht     processed event event.EvtLocalReachabilityChanged; performing dht mode switch
09-03 19:44:29.772 17966 18008 I GoLog   : 2021-09-03 16:44:29  INFO    dht     switched DHT mode successfully  {"mode": 2}
09-03 19:44:33.164 17966 17966 D FileSaver: Save as Method Called
09-03 19:44:33.164 17966 17966 D Dialog Activity: Opening File Manager
09-03 19:44:33.191 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.inactive
09-03 19:44:33.293 17966 17997 D EGL_emulation: eglMakeCurrent: 0x75ba306304a0: ver 3 1 (tinfo 0x75ba306fe5c0)
09-03 19:44:33.660 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.paused
09-03 19:44:38.755 17966 17966 D Dialog Activity: Starting file operation
09-03 19:44:38.760 17966 17966 D Dialog Activity: Saving file
09-03 19:44:38.761 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.resumed
09-03 19:44:38.773 17966 17966 D Dialog Activity: Something went wrong
09-03 19:44:38.812 17966 17987 D EGL_emulation: eglMakeCurrent: 0x75ba2d862560: ver 3 1 (tinfo 0x75ba2d990620)
09-03 19:44:38.816 17966 17987 D EGL_emulation: eglMakeCurrent: 0x75ba2d862560: ver 3 1 (tinfo 0x75ba2d990620)
09-03 19:44:38.843 17966 17997 D EGL_emulation: eglMakeCurrent: 0x75ba306304a0: ver 3 1 (tinfo 0x75ba306fe5c0)
09-03 19:44:41.576 17966 17966 D FilePickerDelegate: Selected type */*
09-03 19:44:41.592 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.inactive
09-03 19:44:41.714 17966 17997 D EGL_emulation: eglMakeCurrent: 0x75ba306304a0: ver 3 1 (tinfo 0x75ba306fe5c0)
09-03 19:44:42.086 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.paused


09-03 19:46:02.914 17966 17966 D Dialog Activity: Starting file operation
09-03 19:46:02.915 17966 18071 I FilePickerUtils: Caching from URI: content://com.android.providers.downloads.documents/document/14
09-03 19:46:02.925 17966 17966 D Dialog Activity: Saving file
09-03 19:46:02.926 17966 17986 I flutter : didChangeAppLifecycleState AppLifecycleState.resumed
09-03 19:46:02.927 17966 17966 D Dialog Activity: Error while writing filePermission Denial: writing com.android.providers.downloads.DownloadStorageProvider uri content://com.android.providers.downloads.documents/document/14 from pid=17966, uid=10067 requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission()
09-03 19:46:02.935 17966 18071 D FilePickerUtils: File loaded and cached at:/data/user/0/com.anywherelan.awl/cache/file_picker/config_awl.json
09-03 19:46:02.936 17966 18071 D FilePickerDelegate: File path:[com.mr.flutter.plugin.filepicker.FileInfo@339d486]
09-03 19:46:02.937 17966 17966 D Dialog Activity: Exception while saving fileReply already submitted
09-03 19:46:02.937 17966 17966 D Dialog Activity: Something went wrong
09-03 19:46:02.954 17966 17971 I zygote64: Do partial code cache collection, code=61KB, data=56KB
09-03 19:46:02.955 17966 17971 I zygote64: After code cache collection, code=61KB, data=56KB
09-03 19:46:02.955 17966 17971 I zygote64: Increasing code cache capacity to 256KB
--------- beginning of crash
09-03 19:46:02.992 17966 17966 E AndroidRuntime: FATAL EXCEPTION: main
09-03 19:46:02.992 17966 17966 E AndroidRuntime: Process: com.anywherelan.awl, PID: 17966
09-03 19:46:02.992 17966 17966 E AndroidRuntime: java.lang.IllegalStateException: Reply already submitted
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:164)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:243)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at com.one.file_saver.Dialog$completeFileOperation$1.invokeSuspend(Dialog.kt:72)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:790)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:99)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6494)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
09-03 19:46:02.992 17966 17966 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Reproduced with android 8.1 and 11, file_saver library version b0b83c6 and 0.0.10.

How to save file to external storage in android 11

Hi incredibleZayed,
i want to thank you about your great package that helped me very much,
i want to ask how to implement the function of your example on android 11
i could save the pdf file i downloaded through http package to external storage when i used : write external storage, read external storage permission and it worked perfectly.
when i used for android 11 i had to add Manage_External_Storage permission to work, but this solution not the best since my app is rejected by google due to this permission while my app is not mainly for processing user files.

  • so i want to ask what is the best solution to use your package with android 11 and get my app accepted by google play.

How do I download from Firebase Storage?

Hi,
I'm interested in using file_saver package to download an image from Firebase Storage for flutter web.

First off, thanks for your incredible efforts. I'd like to use file_saver package to download from Firebase Storage.

I think that an example on how to do this will boost the usability of the file_saver package because most flutter coders use Firebase.

I'll greatly appreciate when you show me how to download.

Thank you & Blessings,
Kimbowa Aloysius,
Uganda

Flutter web application download failed - path = Something went wrong, please report the issue https://www.github.com/incrediblezayed/file_saver/issues

Hi,

I tried this package to download the pdf file in flutter web application using the below code and its working fine if i run this web application in localhost.

  final pdfData =
      await _generatePdf(eventdata, eventAttendeeEntry, typeOfReceipt);
  await Printing.layoutPdf(onLayout: (format) => pdfData);

  MimeType type = MimeType.PDF;
  String path = await FileSaver.instance.saveFile(
      'print_receipt_${eventAttendeeEntry.eventAttendeeEntryId}_${eventAttendeeEntry.eventAttendeeEntryPrintReceiptId}',
      pdfData,
      "pdf",
      mimeType: type);
  print('path = $path');

But if i deploy in server (firebase hosting) and then if i try then i get the below error. any idea? anything blocking in server?

path = Something went wrong, please report the issue https://www.github.com/incrediblezayed/file_saver/issues

appreciate your response!

saveFile returns file path on iOS, but only directory path on Android

I am using the following code:

  Future<String> saveFile() async {
    String content = "hello";
    Uint8List bytes = Uint8List.fromList(utf8.encode(content));
    final path = await FileSaver.instance.saveFile("testfile", bytes, "txt");
    return path;
  }

On iOS, this function correctly returns the whole file path:

/var/mobile/Containers/Data/Application/8532ACC4-83A1-4557-A6DF-9F5EF7F0F724/Documents/testfile.txt

But on Android, it only returns the enclosing directory path without the filename:

/storage/emulated/0/Android/data/com.example.pdf_flutter/files

Is this behaviour expected?

File saver is not working on Flutter 3

\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_saver-0.1.0\android\src\main\kotlin\com\one\file_saver\FileSaverPlugin.kt: (31, 39): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':file_saver:compileDebugKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
Compilation error. See log for more details

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 33s
Exception: Gradle task assembleDebug failed with exit code 1

save method not work on Android

i get that when try save method on Android ,

D/FileSaver( 5937): Dialog was null
D/FileSaver( 5937): Creating File Dialog Activity
D/FileSaver( 5937): Activity was null
D/FileSaver( 5937): Get directory Method Called
D/FileSaver( 5937): Error While Calling methodnull

[Web] Missing extension

Hi, I see you are adding extension to method channel arguments here, but you are not retrieving it here, so the file is saved without extension.

Not working on Windows

First of all, thanks for creating this awesome plugin ā¤ļø It works great on web!

Problem

The package README indicates that the plugin is working on Windows, however, it seems that it does not for me.

For me, Windows Flutter apps crash whenever I call FileSaver.instance.saveFile. They simply freeze and after a while the Flutter logs indicate "Lost connection to device."


As I am not sure if this is known / how to triage it, I figured I would create this issue.

Download file without extension

When i use saveFile and i not define ext or define as empty, your script try to extract extension, but when is not present, let say bc its shell script for linux. It always add dot on end.

this line

return '.$extension';

alway add empty dot on end when stricted and also parsed extension is not present.

Mac OS generated code issue

image

I cannot use this plugin on Mac OS:

Target of URI doesn't exist: 'package:file_saver/file_saver_web.dart'.
Try creating the file referenced by the URI, or Try using a URI for a file that does exist.dart(uri_does_not_exist)

Browser crashes saving a large file

I'm using this package to save a file on the default directory on Web. For small files, it works really well, but for large files (above 100Mb) it just crashes the Browser.

As it freezes and crashes, I can't provide a detailed log.

Tested:

  • save a 1Mb file āœ…
  • save 10Mb āœ…
  • save 50Mb āœ…
  • save 80Mb āœ…

After 100Mb, it begins to crash.

You can test trying to save a Uint8List of 100Mb

await FileSaver.instance.saveFile('file_name.txt', Uint8List(104857600), 'text/plain');

Using the version 0.1.1

[BUG] 'Future<Directory?>' is not a subtype of type 'FutureOr<Directory>' [mac OS]

I am getting this error on mac os.

This is the sample code.

() async {
                      var path = await FileSaver.instance.saveFile(
                        DateTime.now().toIso8601String(),
                        pngBytes,
                        "png",
                        mimeType: MimeType.PNG,
                      );
                      debugPrint("$path");
                    }

and this the error I am getting in the console.

flutter: type 'Future<Directory?>' is not a subtype of type 'FutureOr<Directory>' in type cast
flutter: null

Improve CHANGELOG order

A good practice in changelog, place last version in first place

Expected order:

## 0.0.5

* Minor Bug Fixes

## 0.0.4

* saveFile method returns the path where the file is saved.

... older versions

Current order:

... older versions

## 0.0.4

* saveFile method returns the path where the file is saved.

## 0.0.5

* Minor Bug Fixes

Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected in the line C:\AndroidStudio\flutter\.pub-cache\hosted\pub.dartlang.org\file_saver-0.1.0\android\src\main\kotlin\com\one\file_saver\FileSaverPlugin.kt line(30,31)

It is causing build failure
I found the error in the specified file
Error Line:
methodChannel = MethodChannel(messenger, "file_saver")

My Solution:
messenger?.let{
methodChannel = MethodChannel(messenger, "file_saver")
methodChannel?.setMethodCallHandler(this)
}

Module 'file_saver' not found

when run on ios simulator :
Error output from Xcode build:
ā†³
objc[25292]: Class AMSupportURLConnectionDelegate is implemented in both
/usr/lib/libauthinstall.dylib (0x20246ab90) and
/Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice
(0x1081ec2c8). One of the two will be used. Which one is undefined.
objc[25292]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib
(0x20246abe0) and
/Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice
(0x1081ec318). One of the two will be used. Which one is undefined.
** BUILD FAILED **

Xcode's output:
../ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal
error: module 'file_saver' not found
@import file_saver;

*** Assertion failure in -[FlutterStandardWriter writeValue:], FlutterStandardCodec.mm:338

First, thank you for the excellent library - it really seems to be the only one out there that performs this function. Now, on to the problem ;)

I'm trying use the saveAs method on MacOS and I'm getting a funky error after clicking save. The file seems to save properly to the specified location, but throws an error at the end. I spent a number of hours trying to trace the root of the error without any luck. It appears to be coming from the Flutter foundation code, or perhaps the FlutterMacOS code. The fileSave method works fine without any problems, but I want my users to specify the location of the file to be saved, so I need the dialog box. After the error, the method does not seems to return as the Path is not provided.

It doesn't seem to matter what data is saved, or which mime type - it always generates this error.

Unrelated, I would expect this method call to return a valid path without saving when the user selects 'save', but instead it saves the file. The source code backs that up -- it is odd to return the path and save the file. I would expect the path to be returned and let me save separately to the path.

Sample code and stack trace below:

SAMPLE CODE:

void _saveBoard() async {
  logger.d("Save board");
  if (!kIsWeb) {
    if (Platform.isIOS || Platform.isAndroid || Platform.isMacOS) {
      // This does NOT work on MacOS!   
      // bool status = await Permission.storage.isGranted;
      // if (!status) await Permission.storage.request();

      MimeType type = MimeType.TEXT;
      String test = '{"version": 20220601,"costs": { "Walnut": 12.99}}';
      Uint8List data = Uint8List.fromList(test.codeUnits);
      String path =
          await FileSaver.instance.saveAs("File", data, "json", type);
      logger.d("File Path: $path");
      // await FileSaver.instance.saveFile("test", data, "txt");
    }
  }

  logger.d("Complete _saveBoard");
}

STACK TRACE:

Reloaded 1 of 1086 libraries in 326ms.
flutter: [DEBUG  ]  MyToolbar._saveBoard: Save board
2022-06-02 17:04:20.587 Cutting Board Builder[30991:5328835] Unsupported value: file:///Users/user/Desktop/test.json of type NSURL
2022-06-02 17:04:20.587 Cutting Board Builder[30991:5328835] *** Assertion failure in -[FlutterStandardWriter writeValue:], FlutterStandardCodec.mm:338
2022-06-02 17:04:20.590 Cutting Board Builder[30991:5328835] -[NSSavePanel didEndPanelWithReturnCode:] caught non-fatal NSInternalInconsistencyException 'Unsupported value for standard codec' with user dictionary {
    NSAssertFile = "FlutterStandardCodec.mm";
    NSAssertLine = 338;
} and backtrace (
	0   CoreFoundation                      0x00007ff80e8087b3 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff80e568bc3 objc_exception_throw + 48
	2   Foundation                          0x00007ff80f6bad13 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 267
	3   FlutterMacOS                        0x00000001099fb617 -[FlutterStandardWriter writeValue:] + 999
	4   FlutterMacOS                        0x00000001099fa1b5 -[FlutterStandardMethodCodec encodeSuccessEnvelope:] + 117
	5   FlutterMacOS                        0x00000001099f7e5a __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke_2 + 154
	6   file_saver                          0x000000010619c2ee $syXlSgIeyBy_ypSgIegn_TR + 190
	7   file_saver                          0x000000010619a519 $s10file_saver6DialogC8saveFile33_D4C5CDA81D09C203BAC31A1F4939CEC0LL8byteData3url0A4Name3ext6resultySays5UInt8VG_10Foundation3URLVS2SyypSgctF + 441
	8   file_saver                          0x000000010619a162 $s10file_saver6DialogC010openSaveAsC06params6resultyAA6ParamsV_yypSgctFySo15NSModalResponseacfU_ + 1138
	9   file_saver                          0x000000010619a2d0 $sSo15NSModalResponseaIegy_ABIeyBy_TR + 48
	10  AppKit                              0x00007ff811bd420e -[NSSavePanel didEndPanelWithReturnCode:] + 76
	11  AppKit                              0x00007ff811bd4460 -[NSSavePanel completeModeless:] + 23
	12  AppKit                              0x00007ff811bd4769 -[NSSavePanel completeWithReturnCode:url:urls:] + 449
	13  AppKit                              0x00007ff811bd679a -[NSSavePanel observeValueForKeyPath:ofObject:change:context:] + 325
	14  Foundation                          0x00007ff80f5c31aa NSKeyValueNotifyObserver + 306
	15  Foundation                          0x00007ff80f6870b9 NSKeyValueDidChange + 431
	16  Foundation                          0x00007ff80f72f84e NSKeyValueDidChangeWithPerThreadPendingNotifications + 146
	17  ViewBridge                          0x00007ff815cf6091 __41-[NSViewBridge setObject:forKey:withKVO:]_block_invoke + 360
	18  ViewBridge                          0x00007ff815d76701 withHintInProgress + 198
	19  ViewBridge                          0x00007ff815cedf77 -[NSViewBridge setObject:forKey:withKVO:] + 417
	20  ViewBridge                          0x00007ff815cef1cc -[NSViewBridge nonLocalChangeInProgress:block:] + 172
	21  ViewBridge                          0x00007ff815ceef8c -[NSRemoteViewMarshal exceptionSafeSetRemoteObject:forKey:withReply:] + 264
	22  ViewBridge                          0x00007ff815ceee42 -[NSRemoteViewMarshal setRemoteObject:forKey:withReply:] + 56
	23  CoreFoundation                      0x00007ff80e7709cc __invoking___ + 140
	24  CoreFoundation                      0x00007ff80e770873 -[NSInvocation invoke] + 305
	25  ViewBridge                          0x00007ff815cecf00 __deferNSXPCInvocationOntoMainThread_block_invoke + 228
	26  ViewBridge                          0x00007ff815ce02c4 __wrapBlockWithVoucher_block_invoke + 37
	27  ViewBridge                          0x00007ff815cdff4f __deferBlockOntoMainThread_block_invoke_2 + 274
	28  CoreFoundation                      0x00007ff80e78cd31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	29  CoreFoundation                      0x00007ff80e78cbdc __CFRunLoopDoBlocks + 445
	30  CoreFoundation                      0x00007ff80e78bf4d __CFRunLoopRun + 2609
	31  CoreFoundation                      0x00007ff80e78ae5c CFRunLoopRunSpecific + 562
	32  HIToolbox                           0x00007ff8174325e6 RunCurrentEventLoopInMode + 292
	33  HIToolbox                           0x00007ff81743234a ReceiveNextEventCommon + 594
	34  HIToolbox                           0x00007ff8174320e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
	35  AppKit                              0x00007ff8111ca1fd _DPSNextEvent + 927
	36  AppKit                              0x00007ff8111c88ba -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394
	37  AppKit                              0x00007ff8113cc810 -[NSWindow(NSEventRouting) trackEventsMatchingMask:timeout:mode:handler:] + 261
	38  ViewBridge                          0x00007ff815d53e98 -[NSRemoteView _beginTrackingLoop:reply:] + 379
	39  ViewBridge                          0x00007ff815d56be4 -[NSRemoteViewMarshal beginTrackingLoop:reply:] + 48
	40  CoreFoundation                      0x00007ff80e7709cc __invoking___ + 140
	41  CoreFoundation                      0x00007ff80e770873 -[NSInvocation invoke] + 305
	42  ViewBridge                          0x00007ff815cecf00 __deferNSXPCInvocationOntoMainThread_block_invoke + 228
	43  ViewBridge                          0x00007ff815ce02c4 __wrapBlockWithVoucher_block_invoke + 37
	44  ViewBridge                          0x00007ff815cdff4f __deferBlockOntoMainThread_block_invoke_2 + 274
	45  CoreFoundation                      0x00007ff80e78cd31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	46  CoreFoundation                      0x00007ff80e78cbdc __CFRunLoopDoBlocks + 445
	47  CoreFoundation                      0x00007ff80e78bf4d __CFRunLoopRun + 2609
	48  CoreFoundation                      0x00007ff80e78ae5c CFRunLoopRunSpecific + 562
	49  HIToolbox                           0x00007ff8174325e6 RunCurrentEventLoopInMode + 292
	50  HIToolbox                           0x00007ff81743234a ReceiveNextEventCommon + 594
	51  HIToolbox                           0x00007ff8174320e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
	52  AppKit                              0x00007ff8111ca1fd _DPSNextEvent + 927
	53  AppKit                              0x00007ff8111c88ba -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394
	54  AppKit                              0x00007ff8111baf69 -[NSApplication run] + 586
	55  AppKit                              0x00007ff81118eee7 NSApplicationMain + 817
	56  Cutting Board Builder               0x00000001060659e9 main + 9
	57  dyld                                0x000000010e03351e start + 462
)
2022-06-02 17:04:20.593 Cutting Board Builder[30991:5328835] -[NSSavePanel observeValueForKeyPath:ofObject:change:context:] caught non-fatal NSInternalInconsistencyException 'Unsupported value for standard codec' with user dictionary {
    NSAssertFile = "FlutterStandardCodec.mm";
    NSAssertLine = 338;
} and backtrace (
	0   CoreFoundation                      0x00007ff80e8087b3 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff80e568bc3 objc_exception_throw + 48
	2   Foundation                          0x00007ff80f6bad13 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 267
	3   FlutterMacOS                        0x00000001099fb617 -[FlutterStandardWriter writeValue:] + 999
	4   FlutterMacOS                        0x00000001099fa1b5 -[FlutterStandardMethodCodec encodeSuccessEnvelope:] + 117
	5   FlutterMacOS                        0x00000001099f7e5a __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke_2 + 154
	6   file_saver                          0x000000010619c2ee $syXlSgIeyBy_ypSgIegn_TR + 190
	7   file_saver                          0x000000010619a519 $s10file_saver6DialogC8saveFile33_D4C5CDA81D09C203BAC31A1F4939CEC0LL8byteData3url0A4Name3ext6resultySays5UInt8VG_10Foundation3URLVS2SyypSgctF + 441
	8   file_saver                          0x000000010619a162 $s10file_saver6DialogC010openSaveAsC06params6resultyAA6ParamsV_yypSgctFySo15NSModalResponseacfU_ + 1138
	9   file_saver                          0x000000010619a2d0 $sSo15NSModalResponseaIegy_ABIeyBy_TR + 48
	10  AppKit                              0x00007ff811bd420e -[NSSavePanel didEndPanelWithReturnCode:] + 76
	11  AppKit                              0x00007ff811bd4460 -[NSSavePanel completeModeless:] + 23
	12  AppKit                              0x00007ff811bd4769 -[NSSavePanel completeWithReturnCode:url:urls:] + 449
	13  AppKit                              0x00007ff811bd679a -[NSSavePanel observeValueForKeyPath:ofObject:change:context:] + 325
	14  Foundation                          0x00007ff80f5c31aa NSKeyValueNotifyObserver + 306
	15  Foundation                          0x00007ff80f6870b9 NSKeyValueDidChange + 431
	16  Foundation                          0x00007ff80f72f84e NSKeyValueDidChangeWithPerThreadPendingNotifications + 146
	17  ViewBridge                          0x00007ff815cf6091 __41-[NSViewBridge setObject:forKey:withKVO:]_block_invoke + 360
	18  ViewBridge                          0x00007ff815d76701 withHintInProgress + 198
	19  ViewBridge                          0x00007ff815cedf77 -[NSViewBridge setObject:forKey:withKVO:] + 417
	20  ViewBridge                          0x00007ff815cef1cc -[NSViewBridge nonLocalChangeInProgress:block:] + 172
	21  ViewBridge                          0x00007ff815ceef8c -[NSRemoteViewMarshal exceptionSafeSetRemoteObject:forKey:withReply:] + 264
	22  ViewBridge                          0x00007ff815ceee42 -[NSRemoteViewMarshal setRemoteObject:forKey:withReply:] + 56
	23  CoreFoundation                      0x00007ff80e7709cc __invoking___ + 140
	24  CoreFoundation                      0x00007ff80e770873 -[NSInvocation invoke] + 305
	25  ViewBridge                          0x00007ff815cecf00 __deferNSXPCInvocationOntoMainThread_block_invoke + 228
	26  ViewBridge                          0x00007ff815ce02c4 __wrapBlockWithVoucher_block_invoke + 37
	27  ViewBridge                          0x00007ff815cdff4f __deferBlockOntoMainThread_block_invoke_2 + 274
	28  CoreFoundation                      0x00007ff80e78cd31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	29  CoreFoundation                      0x00007ff80e78cbdc __CFRunLoopDoBlocks + 445
	30  CoreFoundation                      0x00007ff80e78bf4d __CFRunLoopRun + 2609
	31  CoreFoundation                      0x00007ff80e78ae5c CFRunLoopRunSpecific + 562
	32  HIToolbox                           0x00007ff8174325e6 RunCurrentEventLoopInMode + 292
	33  HIToolbox                           0x00007ff81743234a ReceiveNextEventCommon + 594
	34  HIToolbox                           0x00007ff8174320e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
	35  AppKit                              0x00007ff8111ca1fd _DPSNextEvent + 927
	36  AppKit                              0x00007ff8111c88ba -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394
	37  AppKit                              0x00007ff8113cc810 -[NSWindow(NSEventRouting) trackEventsMatchingMask:timeout:mode:handler:] + 261
	38  ViewBridge                          0x00007ff815d53e98 -[NSRemoteView _beginTrackingLoop:reply:] + 379
	39  ViewBridge                          0x00007ff815d56be4 -[NSRemoteViewMarshal beginTrackingLoop:reply:] + 48
	40  CoreFoundation                      0x00007ff80e7709cc __invoking___ + 140
	41  CoreFoundation                      0x00007ff80e770873 -[NSInvocation invoke] + 305
	42  ViewBridge                          0x00007ff815cecf00 __deferNSXPCInvocationOntoMainThread_block_invoke + 228
	43  ViewBridge                          0x00007ff815ce02c4 __wrapBlockWithVoucher_block_invoke + 37
	44  ViewBridge                          0x00007ff815cdff4f __deferBlockOntoMainThread_block_invoke_2 + 274
	45  CoreFoundation                      0x00007ff80e78cd31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	46  CoreFoundation                      0x00007ff80e78cbdc __CFRunLoopDoBlocks + 445
	47  CoreFoundation                      0x00007ff80e78bf4d __CFRunLoopRun + 2609
	48  CoreFoundation                      0x00007ff80e78ae5c CFRunLoopRunSpecific + 562
	49  HIToolbox                           0x00007ff8174325e6 RunCurrentEventLoopInMode + 292
	50  HIToolbox                           0x00007ff81743234a ReceiveNextEventCommon + 594
	51  HIToolbox                           0x00007ff8174320e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
	52  AppKit                              0x00007ff8111ca1fd _DPSNextEvent + 927
	53  AppKit                              0x00007ff8111c88ba -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394
	54  AppKit                              0x00007ff8111baf69 -[NSApplication run] + 586
	55  AppKit                              0x00007ff81118eee7 NSApplicationMain + 817
	56  Cutting Board Builder               0x00000001060659e9 main + 9
	57  dyld                                0x000000010e03351e start + 462
)

Flutter Doctor:

cutting_board_maker % flutter -v doctor
[āœ“] Flutter (Channel stable, 3.0.0, on macOS 12.4 21F79 darwin-x64, locale en-US)
    ā€¢ Flutter version 3.0.0 at /Users/user/Development/Flutter/flutter
    ā€¢ Upstream repository https://github.com/flutter/flutter.git
    ā€¢ Framework revision ee4e09cce0 (3 weeks ago), 2022-05-09 16:45:18 -0700
    ā€¢ Engine revision d1b9a6938a
    ā€¢ Dart version 2.17.0
    ā€¢ DevTools version 2.12.2

[āœ—] Android toolchain - develop for Android devices
    āœ— Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[āœ“] Xcode - develop for iOS and macOS (Xcode 13.4)
    ā€¢ Xcode at /Applications/Xcode.app/Contents/Developer
    ā€¢ CocoaPods version 1.11.2

[āœ“] Chrome - develop for the web
    ā€¢ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    ā€¢ Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[āœ“] VS Code (version 1.67.2)
    ā€¢ VS Code at /Applications/Visual Studio Code.app/Contents
    ā€¢ Flutter extension version 3.42.0

[āœ“] Connected device (2 available)
    ā€¢ macOS (desktop) ā€¢ macos  ā€¢ darwin-x64     ā€¢ macOS 12.4 21F79 darwin-x64
    ā€¢ Chrome (web)    ā€¢ chrome ā€¢ web-javascript ā€¢ Google Chrome 102.0.5005.61

[āœ“] HTTP Host Availability
    ā€¢ All required HTTP hosts are available

! Doctor found issues in 2 categories.
cutting_board_maker % 

_openFileManager crashes app when Cancel button is clicked

Flutter 2.10.3
iPhone12 Pro Max simulator + iPhone 12 Pro real device

await FileSaver.instance
.saveAs(fileName, response.bodyBytes, '.pdf', MimeType.PDF)
.whenComplete(() => print("DONE"));

This works great when I save the file to the storage. But if click to Cancel on the left top, the app crashes and on real device unable to open the app again :)

I checked the package and saw that:
_openFileManager crashes app because when cancel clicked _path! returns null which means definitely will definitely break the app. ("Null check operator used on a null value" is the exact error)
What I've done further to check if it works (not good idea to manipulate packages but just for testing purposes):
I changed _openFileManager function a little bit like:
return _path ?? ""; instead of return _path!;

This worked great. Can you please fix the error?
Btw, thanks for the great package. I highly appreciate your work.
Simulator Screen Shot - iPhone 12 Pro Max - 2022-05-16 at 16 28 48

Issue in flutter 3.0.0 with kt

I can't run my app with this issue.

flutter/.pub-cache/hosted/pub.dartlang.org/file_saver-0.1.0/android/src/main/kotlin/com/one/file_saver/FileSaverPlugin.kt: (31, 39): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

Wrong call

I guess the comment is wrong. Right now is working on iphone, right?
image

Can't save on mobile

Works perfectly on web. I am testing it on my Android device and it keeps giving me this error, although the permissions are granted:

FileSystemException: Cannot open file, path = '/storage/emulated/0/Download/Restaurapp QR Download.png' (OS Error: Operation not permitted, errno = 1)

My code looks like this:

_screenshotController.capture(delay: Duration(milliseconds: 10)).then((Uint8List? screenshot) async{
              if(screenshot != null){
                if (!kIsWeb) {
                  if (Platform.isIOS || Platform.isAndroid) {
                    bool status = await Permission.storage.isGranted;
                    if (!status) await Permission.storage.request();

                    status = await Permission.storage.isGranted;

                    if(status)
                      await FileSaver.instance.saveFile('Restaurapp QR Download', screenshot, 'png');
                  }
                }else{
                  await FileSaver.instance.saveFile('Restaurapp QR Download', screenshot, 'png');
                }

              }else{
                generateSnackBar(false, S.of(context).failedDownloadText, context);
              }

Am I doing something wrong?

file_saver-0.1.0 Build error : Type mismatch

I cannot build for android on the latest flutter beta version (details attached below).

Gradle error :
e: C:\Flutter.pub-cache\hosted\pub.dartlang.org\file_saver-0.1.0\android\src\main\kotlin\com\one\file_saver\FileSaverPlugin.kt: (31, 39): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

FAILURE: Build failed with an exception.

Flutter:
Flutter 2.12.0-4.1.pre ā€¢ channel beta ā€¢ https://github.com/flutter/flutter.git
Framework ā€¢ revision 680962aa75 (6 days ago) ā€¢ 2022-03-16 13:46:03 -0700
Engine ā€¢ revision e9f57b5d0f
Tools ā€¢ Dart 2.17.0 (build 2.17.0-182.1.beta) ā€¢ DevTools 2.11.1

Not getting path of save file in iOS

as in android, we are getting path at which file will save, but in iOS we are not getting path of file but are getting ios verison as iOS 14.5

saveFile option not saving .srt file to downloads folder on android

saveFile option not saving .srt file to downloads folder on android. Also on using saveAs option on android, the extension is not applied when file is saved. It is just saving with filename and no extension. I am using MimeType.OTHER and also using .srt as ext type,

It's not working on web release

Hi,

I'm using await FileSaver.instance.saveFile(name, savingData, fileExt, mimeType: MimeType.OTHER); code for saving file on Web.
It's working on debug mode but when i published to hosting it's not working. Is it bug or what am I doing wrong?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.