utils library

Functions

cacheFile(String name) Future<File>
This function creates temporary file on the device storage Return File You can call normal File methods
copy(String targetPath, String destination) → void
createFolderByPath(String path, {String? folderName}) Future<Directory>
Create folder by path
deleteAll(List<FileSystemEntity> files) Future<void>
e.g:
deleteDir(String path, {dynamic recursive = false}) bool
Delete a directory recursively or not
details(dynamic path) Future<Map?>
Returns a HashMap containing detials of the file or the directory in organised style. you can use details from Directory or File instead this function.
fileStream(String path, {dynamic changeCurrentPath = true, dynamic reverse = false, dynamic recursive = false, dynamic keepHidden = false}) Stream<List<FileSystemEntity>>
keepHidden: show files that start with .
getBaseName(String? path, {bool extension = true}) String
Return the name of the file or the folder i.e: /root/home/myfile.zip = myfile.zip extension: with extension true or not false, true by default
getExternalStorageWithoutDataDir(String unfilteredPath) Future<Directory>
This function aims to get path like: /storage/emulated/0/ not like /storage/emulated/0/Android/data/package.name.example/files
getStorageList() Future<List<Directory>>
Return all paths
isHidden(String path, String root) bool
listDirectories(Directory path, {dynamic excludeHidden = false, dynamic followLinks = false, FlutterFileUtilsSorting? sortedBy, bool reversed = false}) Future<List<Directory>>
Return a List of directories starting from the given path
listFiles(String path, {List<String>? extensions, dynamic followsLinks = false, dynamic excludeHidden = false, FlutterFileUtilsSorting? sortedBy, bool reversed = false}) Future<List<File>>
This function returns files' paths list only from specific location.
listFolders(Directory path, {List<String>? excludedFolders, List<String>? excludedPaths, bool excludeHidden = false, dynamic followLinks = false, FlutterFileUtilsSorting? sortedBy, bool reversed = false}) Future<List<String>>
This function return list of folders of type String , not full paths Directory.
rename(String target, String destination) Future<Directory>
searchStream(dynamic path, String query, {bool matchCase = false, dynamic recursive = true, bool hidden = false}) Stream<List<FileSystemEntity>>
search for files and folder in current directory & sub-directories, and return File or Directory
sortBy(List objects, FlutterFileUtilsSorting? by, {bool reversed = false}) List
  • argument objects = File or Directory
  • argument by String: 'date', 'alpha', 'size'
  • splitPathToDirectories(String fullPath) List<Directory>
    This function returns every Directory in the path independently