A package that provides a friendly Dart API for file and directory selection for Windows using common dialog controls.
This package builds on top of the Dart win32 package, offering a high-level Dart wrapper that avoids the need for users to understand FFI or write directly to the Win32 API.
Show a file picker dialog, allowing the user to select a file.
import 'package:filepicker_windows/filepicker_windows.dart';
void main() {
final file = OpenFilePicker()
..filterSpecification = {
'Word Document (*.doc)': '*.doc',
'Web Page (*.htm; *.html)': '*.htm;*.html',
'Text Document (*.txt)': '*.txt',
'All Files': '*.*'
}
..defaultFilterIndex = 0
..defaultExtension = 'doc'
..title = 'Select a document';
final result = file.getFile();
if (result != null) {
print(result.path);
}
}
Show a directory picker dialog, allowing the user to select a directory.
import 'package:filepicker_windows/filepicker_windows.dart';
void main() {
final file = DirectoryPicker()..title = 'Select a directory';
final result = file.getDirectory();
if (result != null) {
print(result.path);
}
}
Additional examples can be located within the example directory.
For a more advanced demonstration, you can explore a Flutter application in the
example\wallpaper\
directory. This application illustrates how to select an
image file and set it as your desktop wallpaper.
Please file feature requests and bugs at the issue tracker.