FilePicker class

A file picker that shows one directory at a time as a scrollable list and passes the file the user chooses to onSelect.

Up and Down move the cursor, wrapping at the ends, and Home and End jump. Enter, Right, or a click on a row opens a folder in place or chooses a file; on a link or other entry, they do nothing. Left or Backspace, or a click on the .. row, goes to the parent directory.

FilePicker(
  initialDirectory: '/home/user/projects',
  filter: (entry) => entry.isDirectory || entry.name.endsWith('.dart'),
  onSelect: (file) => openInEditor(file.path),
)

It lists directories from source: the local disk by default on native platforms. A browser embed passes one, such as a MemoryFileSource. It reads a directory when it opens one or is given a different source; filter and showHidden narrow what was read. Directory reads are synchronous — fine for a picker UI on local disks, but don't point this at a slow network mount.

Inheritance
Available extensions

Constructors

FilePicker({Key? key, required String initialDirectory, required void onSelect(FileEntry file), FileSource? source, FileEntryFilter? filter, bool showHidden = false, int maxVisible = 12, String semanticLabel = 'Files', FocusNode? focusNode, bool autofocus = false})
const

Properties

autofocus → bool
Whether the picker requests focus when mounted.
final
filter → FileEntryFilter?
Optional predicate that hides entries: return false to skip one. It runs on the entries of the directory that pass the showHidden rule. Use it to filter by extension, hide build artifacts, and so on.
final
focusNode → FocusNode?
Focus node used for keyboard navigation.
final
hashCode → int
The hash code for this object.
no setterinherited
initialDirectory → String
Directory the picker opens in. If it can't be listed (missing or unreadable), the picker renders a dim error row instead of entries.
final
key → Key?
finalinherited
maxVisible → int
Maximum rows shown at once; longer directories scroll within this height, keeping the cursor in view.
final
onSelect → void Function(FileEntry file)
Called with the chosen file when the user presses Enter or Right on a file row, or clicks it. Directories open in place instead; links and other non-file entries do nothing.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel → String
Label exposed through the semantic app graph.
final
showHidden → bool
Whether to list hidden entries, such as dot-files. Defaults to false. Like a new filter, a change applies to the entries already read and keeps the cursor on its entry.
final
source → FileSource?
Where directories are read from. Defaults to the local disk on native platforms; in the browser, pass one, such as a MemoryFileSource.
final

Methods

animate({Duration? duration, Curve? curve, Object? trigger, bool repeat = false}) → Animate

Available on Widget, provided by the AnimateExtension extension

Starts an Animate chain over this widget. duration / curve apply to the whole chain. With no trigger it plays on mount; with a non-null trigger it rests on mount and replays whenever the token changes.
createElement() → StatefulElement
Creates the Element that will mount this widget into the tree.
inherited
createState() → State<FilePicker>
Creates the mutable state for this widget at the current location in the tree. Called exactly once per StatefulElement instance.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited