FilePickerModel class

A file picker model for navigating and selecting files.

The file picker displays a list of files and directories and allows the user to navigate through the file system and select files.

Example:

final picker = FilePickerModel(
  currentDirectory: Directory.current.path,
  allowedTypes: ['.dart', '.yaml'],
);
final (model, cmd) = picker.init();
Inheritance

Constructors

FilePickerModel({required String currentDirectory, List<String>? allowedTypes, bool fileAllowed = true, bool dirAllowed = false, bool showHidden = false, bool showPermissions = true, bool showSize = true, int height = 10, bool autoHeight = true, String cursor = '> ', FilePickerKeyMap? keyMap, FilePickerStyles? styles})
Creates a new file picker model.

Properties

allowedTypes List<String>
The list of allowed file extensions.
no setter
autoHeight bool
Whether the height is automatically adjusted.
no setter
currentDirectory String
The current directory being displayed.
no setter
cursor String
The cursor string.
no setter
dirAllowed bool
Whether directories can be selected.
no setter
errorMessage String?
Last error message (read failures, disabled selection, etc.).
no setter
fileAllowed bool
Whether files can be selected.
no setter
files List<FileEntry>
The files in the current directory.
no setter
hashCode int
The hash code for this object.
no setterinherited
height int
The visible height of the file list.
no setter
id int
Internal ID for this file picker.
no setter
keyMap FilePickerKeyMap
The key map.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selected int
The currently selected index.
no setter
selectedPath String?
The selected file/directory path (null if nothing selected).
no setter
showHidden bool
Whether hidden files are shown.
no setter
showPermissions bool
Whether permissions are shown.
no setter
showSize bool
Whether file sizes are shown.
no setter
styles FilePickerStyles
The styles.
no setter

Methods

canSelect(String fileName) bool
Checks if a file can be selected based on allowed types.
copyWith({String? currentDirectory, List<String>? allowedTypes, bool? fileAllowed, bool? dirAllowed, bool? showHidden, bool? showPermissions, bool? showSize, int? height, bool? autoHeight, String? cursor, FilePickerKeyMap? keyMap, FilePickerStyles? styles, List<FileEntry>? files, int? selected, int? min, int? max, String? selectedPath, bool clearSelectedPath = false, List<_ViewState>? selectedStack, int? id, String? errorMessage, bool clearError = false}) FilePickerModel
Creates a copy of this model with the given fields replaced.
didSelectDisabledFile(Msg msg) → (bool, String?)
Returns whether a disabled file was selected on this message.
didSelectFile(Msg msg) → (bool, String?)
Returns whether a file was selected on this message.
init() Cmd?
Initializes the file picker.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setAllowedExtensions(List<String> extensions) → void
Sets the allowed file extensions.
setDirAllowed(bool allowed) → void
Sets whether directories can be selected.
setFileAllowed(bool allowed) → void
Sets whether files can be selected.
setHeight(int h) → void
Sets the height of the file picker.
setWidth(int w) → void
Sets the width of the file picker (currently no-op as it's dynamic).
toString() String
A string representation of this object.
inherited
update(Msg msg) → (FilePickerModel, Cmd?)
Updates the component state in response to a message.
override
view() String
Renders the current model state for display.
override

Operators

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