v0.3.0
Major release focused on support for Storage Access Framework.
Breaking Changes
minSdkVersionset to19.getMediaStoreContentDirectoryreturn type changed toUri.- Import package directive path is now modular. Which means you need to import the modules you are using:
import 'package:shared_storage/saf.dart' as saf;to enable Storage Access Framework API.import 'package:shared_storage/environment.dart' as environment;to enable Environment API.import 'package:shared_storage/media_store.dart' as mediastore;to enable Media Store API.import 'package:shared_storage/shared_storage' as sharedstorage;if you want to import all above and as a single module (Not recommended because can conflict/override names/methods).
New Features
See the label reference here.
-
Original
listFiles. This API does the same thing asDocumentFile.listFilesbut through Android queries and not calling directly theDocumentFile.listFilesAPI for performance reasons. -
Internal
DocumentFilefromDocumentFileSAF class. -
Internal
QueryMetadatametadata of the queries used bylistFilesAPI. -
Internal
PartialDocumentFile. Represents a partial document file returned bylistFilesAPI. -
openDocumentTreenow acceptsgrantWritePermissionandinitialUriparams which, respectively, sets whether or not grant write permission level and the initial uri location of the folder authorization picker. -
Mirror
DocumentFileColumnfromDocumentsContract.Document.<Column>SAF class. -
Mirror
canReadfromDocumentFile.canRead. Returnstrueif the caller can read the givenuri. -
Mirror
canWritefromDocumentFile.canWrite. Returnstrueif the caller can write to the givenuri. -
Mirror
getDocumentThumbnailfromDocumentsContract.getDocumentThumbnail. Returns the image thumbnail of a givenuri, if any (e.g documents that can show a preview, like image or pdf, otherwisenull). -
Mirror
existsfromDocumentsContract.exists. Returnstrueif a givenuriexists. -
Mirror
buildDocumentUriUsingTreefromDocumentsContract.buildDocumentUriUsingTree. -
Mirror
buildDocumentUrifromDocumentsContract.buildDocumentUri. -
Mirror
buildTreeDocumentUrifromDocumentsContract.buildTreeDocumentUri. -
Mirror
deletefromDocumentFile.delete. Self explanatory. -
Mirror
createDirectoryfromDocumentFile.createDirectory. Creates a new child document file that represents a directory given thedisplayName(folder name). -
Alias
createFile. Alias forcreateFileAsBytesorcreateFileAsStringdepending which params are provided. -
Mirror
createFileAsBytesfromDocumentFile.createFile. Given the parent uri, creates a new child document file that represents a single file given thedisplayName,mimeTypeand itscontentin bytes (file name, file type and file content in raw bytes, respectively). -
Alias
createFileAsString. Alias forcreateFileAsBytes(bytes: Uint8List.fromList('file content...'.codeUnits)). -
Mirror
documentLengthfromDocumentFile.length. Returns the length of the given file (uri) in bytes. Returns 0 if the file does not exist, or if the length is unknown. -
Mirror
lastModifiedfromDocumentFile.lastModified. Returns the time when the given file (uri) was last modified, measured in milliseconds since January 1st, 1970, midnight. Returns 0 if the file does not exist, or if the modified time is unknown. -
Mirror
findFilefromDocumentFile.findFile. Search through listFiles() for the first document matching the given display name, this method has a really poor performance for large data sets, prefer usingchildinstead. -
Mirror
fromTreeUrifromDocumentFile.fromTreeUri. -
Mirror
renameTofromDocumentFile.renameTo. Rename a document file given itsurito the givendisplayName. -
Mirror
parentFilefromDocumentFile.parentFile. Get the parent document of the given document file from its uri. -
Mirror
copyfromDocumentsContract.copyDocument. Copies the given document to the givendestination. -
Original
getDocumentContent. Read a document file from its uri by opening a input stream and returning its bytes. -
External
childfromcom.anggrayudi.storage.file.DocumentFile.child. Find the child file of a given parent uri and child name, null if doesn't exists (faster thanfindFile). -
Original
UNSTABLEopenDocumentFile. Open a file uri in a external app, by starting a new activity withACTION_VIEWIntent. -
Original
UNSTABLEgetRealPathFromUri. Return the real path to work with native oldFileAPI instead Uris, be aware this approach is no longer supported on Android 10+ (API 29+) and though new, this API is marked as deprecated and should be migrated to a scoped-storage approach. -
Alias
getDocumentContentAsString. Alias forgetDocumentContent. Convert all bytes returned by the original method into aString. -
Internal
DocumentBitmapclass added. Commonly used as thumbnail image/bitmap of aDocumentFile. -
Extension
UriDocumentFileUtilsonUri(Accesible byuri.extensionMethod(...)).- Alias
toDocumentFile. Alias forDocumentFile.fromTreeUri(this)which is an alias forfromTreeUri. method: convertthisto the respectiveDocumentFile(if exists, otherwisenull). - Alias
openDocumentFile. Alias foropenDocumentFile.
- Alias
-
Mirror
getDownloadCacheDirectoryfromEnvironment.getDataDirectory. -
Mirror
getStorageDirectoryfromEnvironment.getStorageDirectory.
Deprecation Notices
getExternalStoragePublicDirectorywas marked as deprecated and should be replaced with an equivalent API depending on your use-case, see how to migrategetExternalStoragePublicDirectory. This deprecation is originated from official Android documentation and not by the plugin itself.