gjwgit / rattleng

The New Generation R Analytics Desktop App
GNU General Public License v3.0
20 stars 9 forks source link

Refactor selectFile function to include a default file name parameter #397

Closed Lutra-Fs closed 2 months ago

Lutra-Fs commented 2 months ago

Pull Request Details

What issue does this PR address

Checklist

Complete the check-list below to ensure your branch is ready for PR.

Flutter Style Guide: https://survivor.togaware.com/gnulinux/flutter-style.html

Finalising

Once PR discussion is complete and reviewer has approved:

Lutra-Fs commented 2 months ago

On Linux I do not see a default filename provided when I tap the SAVE button

image

I can provide a screenshot.

Lutra-Fs commented 2 months ago

image

Lutra-Fs commented 2 months ago

image test on Linux. Zenity is the default file manager file-picker trying to use and it seems without your issue.

Lutra-Fs commented 2 months ago

See https://github.com/miguelpruivo/flutter_file_picker/issues/1451 We also may need to add zenity as an optional dependency to provide save function

gjwgit commented 2 months ago

When I click SAVE in the SCRIPT tab the default filename is listed there. May need to check what the difference is. image

gjwgit commented 2 months ago

They look pretty much identical to me: lib/utils/select_file.dart and lib/tabs/script/save_button.dart:

  String? result = await FilePicker.platform.saveFile(
    dialogTitle: 'Save SVG image to a .svg file',
    fileName: defaultFileName,
    type: FileType.custom,
    allowedExtensions: ['svg'],
  );

and

    String? outputPath = await FilePicker.platform.saveFile(
      dialogTitle: 'Choose a file to save',
      fileName: 'script.R',
      type: FileType.custom,
      allowedExtensions: ['R'],
    );

That's odd that the first does not work but the second does. This is on Ubuntu 24.04 running Gnome.

gjwgit commented 2 months ago

Tried a few alternatives. None worked yet. Tested on Lab Linux:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: Couldn't find the executable zenity in the path.
#0      isExecutableOnPath (package:file_picker/src/utils.dart:60)
<asynchronous suspension>
#1      FilePickerLinux._getPathToExecutable (package:file_picker/src/linux/file_picker_linux.dart:127)
<asynchronous suspension>
#2      FilePickerLinux.saveFile (package:file_picker/src/linux/file_picker_linux.dart:91)
<asynchronous suspension>
#3      selectFile (package:rattle/utils/select_file.dart:36)
<asynchronous suspension>
#4      ImagePage.build.<anonymous closure>.<anonymous closure> (package:rattle/widgets/image_page.dart:165)
<asynchronous suspension>

** (rattle:2109544): WARNING **: 20:26:43.615: Attempted to set message handler on an FlBinaryMessenger without an engine

** (rattle:2109544): WARNING **: 20:26:43.615: Attempted to set message handler on an FlBinaryMessenger without an engine
gjwgit commented 2 months ago

We may need to revert to simply asking for a filename in a text field popup until this issue is resolved, perhaps upstream if that's where the problem is? https://github.com/miguelpruivo/flutter_file_picker/issues/1451