generateCommandLineArguments method

List<String> generateCommandLineArguments(
  1. String dialogTitle, {
  2. String fileFilter = '',
  3. String fileName = '',
  4. String initialDirectory = '',
  5. bool multipleFiles = false,
  6. bool pickDirectory = false,
  7. bool saveFile = false,
})

Implementation

List<String> generateCommandLineArguments(
  String dialogTitle, {
  String fileFilter = '',
  String fileName = '',
  String initialDirectory = '',
  bool multipleFiles = false,
  bool pickDirectory = false,
  bool saveFile = false,
}) {
  final arguments = ['-e'];

  String argument = 'choose ';
  if (pickDirectory) {
    argument += 'folder ';
  } else {
    argument += 'file ';

    if (saveFile) {
      argument += 'name ';

      if (fileName.isNotEmpty) {
        argument += 'default name "$fileName" ';
      }
    } else {
      if (fileFilter.isNotEmpty) {
        argument += 'of type {$fileFilter} ';
      }

      if (multipleFiles) {
        argument += 'with multiple selections allowed ';
      }
    }
  }

  if (initialDirectory.isNotEmpty) {
    argument += 'default location "$initialDirectory" ';
  }

  argument += 'with prompt "$dialogTitle"';
  arguments.add(argument);

  return arguments;
}