UFile class abstract
Pick, capture, crop, store, open and share files on all 6 platforms. final UFileData? img = await UFile.pickSingleImage();
Constructors
- UFile()
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 Properties
-
storageChanges
→ Stream<
UStorageEvent> -
Emits when a stored file is added, changed or removed.
no setter
Static Methods
-
copy(
String from, String to, {UStorageBucket bucket = UStorageBucket.support, UStorageBucket? toBucket}) → Future< void> - Copies a stored file to another key.
-
cropImage(
{Uint8List? bytes, String? filePath, UCropOptions options = const UCropOptions(), dynamic action(UFileData file)?}) → Future< UFileData?> -
Opens the cropper for bytes or a file path and returns the cropped image.
await UFile.cropImage(bytes: data, options: const UCropOptions(shape: UCropShape.circle)) -
delete(
String key, {UStorageBucket bucket = UStorageBucket.support}) → Future< void> -
Deletes a stored file.
await UFile.delete("avatar.png") -
deleteAll(
{UStorageBucket? bucket, bool includeDownloads = false}) → Future< void> -
Deletes every stored file (one bucket or all);
includeDownloadsalso deletes downloads. -
deleteExpired(
) → Future< void> - Deletes files whose ttl passed (runs automatically too).
-
excludeFromBackup(
String path) → Future< void> -
Keeps
pathout of iCloud/device backups (iOS, macOS; ignored elsewhere). -
exists(
String key, {UStorageBucket bucket = UStorageBucket.support}) → bool -
True when something is stored under
key. -
exportFile(
String key, String destinationPath, {UStorageBucket bucket = UStorageBucket.support}) → Future< bool> -
Copies the stored file under
keytodestinationPath(not on web). -
freeSpace(
String path) → Future< int?> -
Free bytes on the disk that holds
path(null on web). -
importFile(
String sourcePath, String key, {UStorageBucket bucket = UStorageBucket.support, bool deleteSource = false}) → Future< void> -
Copies a file from disk into app storage under
key(not on web).await UFile.importFile(pickedPath, "docs/contract.pdf") -
initStorage(
{int? cacheMaxBytes}) → Future< void> -
Sets up file storage; initU() already does it.
cacheMaxByteslimits the cache bucket. -
isImageExtension(
String? extension) → bool -
True when
extensionis an image type.UFile.isImageExtension("png")→ true -
move(
String from, String to, {UStorageBucket bucket = UStorageBucket.support, UStorageBucket? toBucket}) → Future< void> - Renames a stored file.
-
open(
String pathOrUri, {String? mimeType}) → Future< bool> -
Opens a file with its default app (web: new tab).
UFile.open("/path/report.pdf") -
openCamera(
{UCameraOptions options = const UCameraOptions(), dynamic action(List< UFileData> )?}) → Future<List< UFileData> > -
Opens the full camera screen (photos and/or video) and returns everything captured. Needs
permission add camera microphone.await UFile.openCamera() -
openStoragePage(
) → Future< void> -
Opens the built-in "Storage" screen (usage per bucket, clear buttons).
UFile.openStoragePage() -
pathOf(
String key, {UStorageBucket bucket = UStorageBucket.support}) → String? -
Real disk path of a stored file (null on web and for vault files).
UFile.pathOf("avatar.png") -
pickFile(
{FileType fileType = FileType.any, List< String> ? allowedExtensions, UCropOptions? crop, dynamic action(UFileData?)?}) → Future<UFileData?> -
Picks one file of any type.
await UFile.pickFile(allowedExtensions: ["pdf"]) -
pickFiles(
{bool allowMultiple = true, FileType fileType = FileType.any, List< String> ? allowedExtensions, UCropOptions? crop, dynamic action(List<UFileData> )?}) → Future<List< UFileData> > -
Opens the system file picker;
allowedExtensionsfilters,cropcrops picked images.await UFile.pickFiles(allowedExtensions: ["pdf", "docx"]) -
pickImage(
{UImageSource source = UImageSource.gallery, bool selfie = false, bool allowMultiple = false, int? maxCount, UCropOptions? crop, UCameraOptions? cameraOptions, dynamic action(List< UFileData> )?}) → Future<List< UFileData> > -
Picks images from the gallery, or takes them with the camera; optional crop. Camera:
permission add camera.await UFile.pickImage(allowMultiple: true, maxCount: 5) -
pickSingleImage(
{UImageSource source = UImageSource.gallery, bool selfie = false, int? imageQuality, UCropOptions? crop, UCameraOptions? cameraOptions, dynamic action(UFileData?)?}) → Future< UFileData?> -
Picks one image from the gallery or camera, optionally cropped.
await UFile.pickSingleImage(crop: const UCropOptions(aspectRatio: 1)) -
pickVideo(
{UImageSource source = UImageSource.gallery, UCameraOptions options = const UCameraOptions(), dynamic action(UFileData?)?}) → Future< UFileData?> -
Picks a video from the gallery, or records one with source camera.
await UFile.pickVideo() -
readBytes(
String key, {UStorageBucket bucket = UStorageBucket.support}) → Future< Uint8List?> -
Reads bytes saved under
key, or null.await UFile.readBytes("avatar.png") -
readCache(
String key) → Future< Uint8List?> - Reads bytes saved with saveCache() (null when evicted).
-
readJson(
String key, {UStorageBucket bucket = UStorageBucket.support}) → Future -
Reads JSON saved under
key. -
readSecure(
String key) → Future< Uint8List?> - Reads bytes saved with saveSecure().
-
readStream(
String key, {UStorageBucket bucket = UStorageBucket.support, int start = 0, int? end}) → Stream< Uint8List> -
Streams a big stored file in chunks, optionally a byte range (video, audio).
UFile.readStream("movie.mp4") -
readString(
String key, {UStorageBucket bucket = UStorageBucket.support}) → Future< String?> -
Reads text saved under
key. -
recordVideo(
{UCameraOptions options = const UCameraOptions(), dynamic action(UFileData?)?}) → Future< UFileData?> -
Records one video. Needs
permission add camera microphone.await UFile.recordVideo() -
reveal(
String pathOrUri) → Future< bool> -
Shows a file in Finder / Explorer / Files / the file manager.
UFile.reveal(path) -
saveAs(
{required String sourcePath, required String fileName, String? mimeType}) → Future< String?> -
"Save as" dialog, then copies
sourcePaththere; returns the new location or null (Android, iOS, macOS, Windows, Linux).await UFile.saveAs(sourcePath: p, fileName: "invoice.pdf") -
saveBytes(
String key, List< int> bytes, {UStorageBucket bucket = UStorageBucket.support, Duration? expireIn, String? mimeType}) → Future<void> -
Saves bytes under
keyin app storage (all platforms; web uses IndexedDB).await UFile.saveBytes("avatar.png", bytes) -
saveCache(
String key, List< int> bytes, {Duration? expireIn}) → Future<void> -
Saves re-creatable cache; the OS/size limit may delete it.
await UFile.saveCache("thumb_1", bytes, expireIn: 7.days) -
saveJson(
String key, Object? value, {UStorageBucket bucket = UStorageBucket.support, Duration? expireIn}) → Future< void> -
Saves any JSON value under
key.await UFile.saveJson("draft", map) -
saveSecure(
String key, List< int> bytes) → Future<void> -
Saves bytes encrypted in the vault (key in Keychain/Keystore).
await UFile.saveSecure("id-card", bytes) -
saveString(
String key, String value, {UStorageBucket bucket = UStorageBucket.support, Duration? expireIn}) → Future< void> -
Saves text under
key.await UFile.saveString("notes.txt", text) -
saveToDownloads(
{required String sourcePath, required String fileName, String? mimeType, String? subfolder}) → Future< String?> -
Copies a local file into the Downloads folder (Android: public Downloads; desktop: ~/Downloads); null on iOS/web.
await UFile.saveToDownloads(sourcePath: p, fileName: "a.pdf") -
sizeOf(
String key, {UStorageBucket bucket = UStorageBucket.support}) → int - Size in bytes of the stored file.
-
storageEntries(
{UStorageBucket? bucket}) → List< UStorageEntry> - Every stored file with size, dates and tags (for a storage screen).
-
storageKeys(
{UStorageBucket bucket = UStorageBucket.support}) → List< String> -
Every key in
bucket. -
storageUsage(
{UStorageBucket? bucket}) → int -
Bytes used by one bucket or all.
UFile.storageUsage().toBKMG() -
takePhoto(
{bool selfie = false, UCropOptions? crop, UCameraOptions? options, dynamic action(UFileData?)?}) → Future< UFileData?> -
Takes one photo, optionally cropped;
selfiestarts with the front camera.await UFile.takePhoto(selfie: true) -
takePhotos(
{int maxCount = 0, bool selfie = false, UCropOptions? crop, UCameraOptions? options, dynamic action(List< UFileData> )?}) → Future<List< UFileData> > -
Takes several photos in one camera session (
maxCount0 = unlimited).await UFile.takePhotos(maxCount: 4) -
trimCache(
) → Future< void> - Shrinks the cache bucket to its size limit now.
-
writeToFile(
Uint8List data, {String extension = "tmp"}) → Future< File> -
Writes bytes to a new temp file and returns it (not on web).
final File f = await UFile.writeToFile(bytes, extension: "pdf")
Constants
-
imageExtensions
→ const Set<
String> - Extensions treated as images.