file_selector 0.8.4+3 copy "file_selector: ^0.8.4+3" to clipboard
file_selector: ^0.8.4+3 copied to clipboard

outdated

Flutter plugin for opening and saving files, or selecting directories, using native file selection UI.

file_selector #

pub package

A Flutter plugin that manages files and interactions with file dialogs.

macOS Web Windows
Support 10.11+ Any Windows 10+

Usage #

To use this plugin, add file_selector as a dependency in your pubspec.yaml file.

macOS #

You will need to add an entitlement for either read-only access:

  <key>com.apple.security.files.user-selected.read-only</key>
  <true/>

or read/write access:

  <key>com.apple.security.files.user-selected.read-write</key>
  <true/>

depending on your use case.

Examples #

Here are small examples that show you how to use the API. Please also take a look at our example app.

Open a single file

final XTypeGroup typeGroup = XTypeGroup(
  label: 'images',
  extensions: <String>['jpg', 'png'],
);
final XFile? file =
    await openFile(acceptedTypeGroups: <XTypeGroup>[typeGroup]);

Open multiple files at once

final XTypeGroup jpgsTypeGroup = XTypeGroup(
  label: 'JPEGs',
  extensions: <String>['jpg', 'jpeg'],
);
final XTypeGroup pngTypeGroup = XTypeGroup(
  label: 'PNGs',
  extensions: <String>['png'],
);
final List<XFile> files = await openFiles(acceptedTypeGroups: <XTypeGroup>[
  jpgsTypeGroup,
  pngTypeGroup,
]);

Saving a file

const String fileName = 'suggested_name.txt';
final String? path = await getSavePath(suggestedName: fileName);
if (path == null) {
  // Operation was canceled by the user.
  return;
}

final Uint8List fileData = Uint8List.fromList('Hello World!'.codeUnits);
const String mimeType = 'text/plain';
final XFile textFile =
    XFile.fromData(fileData, mimeType: mimeType, name: fileName);
await textFile.saveTo(path);
366
likes
0
pub points
99%
popularity

Publisher

verified publisherflutter.dev

Flutter plugin for opening and saving files, or selecting directories, using native file selection UI.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

file_selector_macos, file_selector_platform_interface, file_selector_web, file_selector_windows, flutter

More

Packages that depend on file_selector