A Flutter plugin that manages files and interactions with file dialogs.
macOS | Web | Windows | |
---|---|---|---|
Support | 10.11+ | Any | Windows 10+ |
To use this plugin, add file_selector
as a dependency in your pubspec.yaml file.
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.
Here are small examples that show you how to use the API. Please also take a look at our example app.
final typeGroup = XTypeGroup(label: 'images', extensions: ['jpg', 'png']); final file = await openFile(acceptedTypeGroups: [typeGroup]);
final typeGroup = XTypeGroup(label: 'images', extensions: ['jpg', 'png']); final files = await openFiles(acceptedTypeGroups: [typeGroup]);
final path = await getSavePath(); final name = "hello_file_selector.txt"; final data = Uint8List.fromList("Hello World!".codeUnits); final mimeType = "text/plain"; final file = XFile.fromData(data, name: name, mimeType: mimeType); await file.saveTo(path);