openFiles function

Future<List<XFile>> openFiles({
  1. List<XTypeGroup> acceptedTypeGroups = const <XTypeGroup>[],
  2. String? initialDirectory,
  3. String? confirmButtonText,
})

Opens a file selection dialog and returns the list of paths chosen by the user.

acceptedTypeGroups is a list of file type groups that can be selected in the dialog. How this is displayed depends on the platform, for example:

  • On Windows and Linux, each group will be an entry in a list of filter options.
  • On macOS, the union of all types allowed by all of the groups will be allowed. Throws an ArgumentError if any type groups do not include filters supported by the current platform.

initialDirectory is the full path to the directory that will be displayed when the dialog is opened. When not provided, the platform will pick an initial location.

confirmButtonText is the text in the confirmation button of the dialog. When not provided, the default OS label is used (for example, "Open").

Returns an empty list if the user cancels the operation.

Implementation

Future<List<XFile>> openFiles({
  List<XTypeGroup> acceptedTypeGroups = const <XTypeGroup>[],
  String? initialDirectory,
  String? confirmButtonText,
}) {
  return FileSelectorPlatform.instance.openFiles(
      acceptedTypeGroups: acceptedTypeGroups,
      initialDirectory: initialDirectory,
      confirmButtonText: confirmButtonText);
}