FileService class

A service class for handling file-related operations.

Provides comprehensive utilities for:

  • Determining file types (office documents, images, videos, PDFs, etc.)
  • Launching URLs in the default web browser
  • Creating viewer URLs for office documents and Google Docs
  • Retrieving appropriate icons for different file types
  • Managing temporary directories and file operations

All methods are static, making this a utility class that doesn't require instantiation.

Constructors

FileService()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Static Methods

clearTempDir() → Future<void>
Clears all files and directories from the temporary directory.
createGoogleDocsViewerUrl(String fileUrl) → String
Creates a URL for viewing a file using the Google Docs web viewer.
createOfficeViewerUrl(String fileUrl) → String
Creates a URL for viewing an office file using the Microsoft Office web viewer.
getDirectorySize(Directory directory) → Future<double>
Calculates the total size of all files in the given directory.
iconData(String filename) → IconData
Retrieves the appropriate icon for the given filename based on its extension.
isDocFile(String filename) → bool
Checks if the given filename corresponds to a document file.
isImageFile(String filename) → bool
Checks if the given filename corresponds to an image file.
isOfficeFile(String filename) → bool
Checks if the given filename corresponds to an office file.
isPDFFile(String filename) → bool
Checks if the given filename corresponds to a PDF file.
isPresentationFile(String filename) → bool
Checks if the given filename corresponds to a presentation file.
isSpreadSheetFile(String filename) → bool
Checks if the given filename corresponds to a spreadsheet file.
isSupportedFile(String filename) → bool
Checks if the given filename corresponds to a supported file type.
isVideoFile(String filename) → bool
Checks if the given filename corresponds to a video file.
launchUrl(String url) → Future<void>
Launches the specified URL using the default web browser.
listFilesSync(Directory directory, {String prefix = "File:"}) → Future<void>
Lists all files in the given directory recursively and prints their paths.