FileManager class
FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to feel like part of the Flutter framework.
Sample code
FileManager(
controller: controller,
builder: (context, snapshot) {
final List<FileSystemEntity> entitis = snapshot;
return ListView.builder(
itemCount: entitis.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: FileManager.isFile(entitis[index])
? Icon(Icons.feed_outlined)
: Icon(Icons.folder),
title: Text(FileManager.basename(entitis[index])),
onTap: () {
if (FileManager.isDirectory(entitis[index])) {
controller
.openDirectory(entitis[index]);
} else {
// Perform file-related tasks.
}
},
),
);
},
);
},
),
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FileManager
Constructors
- FileManager({Widget? emptyFolder, Widget? loadingScreen, _ErrorBuilder? errorBuilder, required FileManagerController controller, required _Builder builder, bool hideHiddenEntity = true})
Properties
- builder → _Builder
-
This function allows you to create custom widgets and retrieve a list of entities
List<FileSystemEntity>.
final - controller → FileManagerController
-
Controls the state of the FileManager.
final
- emptyFolder → Widget?
-
For an empty screen, create a custom widget.
final
- errorBuilder → _ErrorBuilder?
-
For an error screen, create a custom widget.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hideHiddenEntity → bool
-
Hide the files and folders that are hidden.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingScreen → Widget?
-
For the loading screen, create a custom widget.
Simple Centered CircularProgressIndicator is provided by default.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _FileManagerState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
basename(
dynamic entity, {bool showFileExtension = true}) → String - Get the basename of Directory or File.
-
createFolder(
String currentPath, String name) → Future< void> - Creates the directory if it doesn't exist.
-
formatBytes(
int bytes, [int precision = 2]) → String - Format bytes to human readable string.
-
getFileExtension(
FileSystemEntity file) → String - Return file extension as String.
-
getStorageList(
) → Future< List< Directory> > - Get list of available storage in the device returns an empty list if there is no storage
-
isDirectory(
FileSystemEntity entity) → bool - return true if FileSystemEntity is a Directory else returns Directory
-
isFile(
FileSystemEntity entity) → bool - check weather FileSystemEntity is File return true if FileSystemEntity is File else returns false
-
requestFilesAccessPermission(
) → Future< void>