shared_storage 0.4.2 shared_storage: ^0.4.2 copied to clipboard
Flutter plugin to work with external storage.
0.4.1 #
0.4.0 #
Fix the current behavior of listFiles
and openDocumentFile
API.
Improvements #
- It's now possible to list contents of all subfolders of a granted Uri opened from
openDocumentTree
(@EternityForest). - Now
ACTION_VIEW
intent builder throughopenDocumentFile
API was fixed. So it's now possible to open any file of any kind in third party apps without needing specify the mime type.
Breaking changes #
- Removed Android specific APIs:
DocumentFile.listFiles
(Now it's only available globally).buildDocumentUriUsingTree
removed due high coupling with Android API (Android specific API that are not useful on any other platforms).buildDocumentUri
removed due high coupling with Android API (Android specific API that are not useful on any other platforms).buildTreeDocumentUri
removed due high coupling with Android API (Android specific API that are not useful on any other platforms).
getDocumentThumbnail
now receives only theuri
param instead of arootUri
and adocumentId
.rootUri
field fromQueryMetadata
was removed due API ambiguity: there's no such concept in the Android API and this is not required by it to work well.
0.3.1 #
Minor improvements and bug fixes:
- Crash when ommiting
DocumentFileColumn.id
column onlistFiles
API. Thanks to @EternityForest. - Updated docs to info that now
DocumentFileColumn.id
column is optional when callinglistFiles
.
0.3.0 #
Major release focused on support for Storage Access Framework
.
Breaking Changes #
minSdkVersion
set to19
.getMediaStoreContentDirectory
return 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.listFiles
but through Android queries and not calling directly theDocumentFile.listFiles
API for performance reasons. -
Internal
DocumentFile
fromDocumentFile
SAF class. -
Internal
QueryMetadata
metadata of the queries used bylistFiles
API. -
Internal
PartialDocumentFile
. Represents a partial document file returned bylistFiles
API. -
openDocumentTree
now acceptsgrantWritePermission
andinitialUri
params which, respectively, sets whether or not grant write permission level and the initial uri location of the folder authorization picker. -
Mirror
DocumentFileColumn
fromDocumentsContract.Document.<Column>
SAF class. -
Mirror
canRead
fromDocumentFile.canRead
. Returnstrue
if the caller can read the givenuri
. -
Mirror
canWrite
fromDocumentFile.canWrite
. Returnstrue
if the caller can write to the givenuri
. -
Mirror
getDocumentThumbnail
fromDocumentsContract.getDocumentThumbnail
. Returns the image thumbnail of a givenuri
, if any (e.g documents that can show a preview, like image or pdf, otherwisenull
). -
Mirror
exists
fromDocumentsContract.exists
. Returnstrue
if a givenuri
exists. -
Mirror
buildDocumentUriUsingTree
fromDocumentsContract.buildDocumentUriUsingTree
. -
Mirror
buildDocumentUri
fromDocumentsContract.buildDocumentUri
. -
Mirror
buildTreeDocumentUri
fromDocumentsContract.buildTreeDocumentUri
. -
Mirror
delete
fromDocumentFile.delete
. Self explanatory. -
Mirror
createDirectory
fromDocumentFile.createDirectory
. Creates a new child document file that represents a directory given thedisplayName
(folder name). -
Alias
createFile
. Alias forcreateFileAsBytes
orcreateFileAsString
depending which params are provided. -
Mirror
createFileAsBytes
fromDocumentFile.createFile
. Given the parent uri, creates a new child document file that represents a single file given thedisplayName
,mimeType
and itscontent
in bytes (file name, file type and file content in raw bytes, respectively). -
Alias
createFileAsString
. Alias forcreateFileAsBytes(bytes: Uint8List.fromList('file content...'.codeUnits))
. -
Mirror
documentLength
fromDocumentFile.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
lastModified
fromDocumentFile.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
findFile
fromDocumentFile.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 usingchild
instead. -
Mirror
fromTreeUri
fromDocumentFile.fromTreeUri
. -
Mirror
renameTo
fromDocumentFile.renameTo
. Rename a document file given itsuri
to the givendisplayName
. -
Mirror
parentFile
fromDocumentFile.parentFile
. Get the parent document of the given document file from its uri. -
Mirror
copy
fromDocumentsContract.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
child
fromcom.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
UNSTABLE
openDocumentFile
. Open a file uri in a external app, by starting a new activity withACTION_VIEW
Intent. -
Original
UNSTABLE
getRealPathFromUri
. Return the real path to work with native oldFile
API 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
DocumentBitmap
class added. Commonly used as thumbnail image/bitmap of aDocumentFile
. -
Extension
UriDocumentFileUtils
onUri
(Accesible byuri.extensionMethod(...)
).- Alias
toDocumentFile
. Alias forDocumentFile.fromTreeUri(this)
which is an alias forfromTreeUri
. method: convertthis
to the respectiveDocumentFile
(if exists, otherwisenull
). - Alias
openDocumentFile
. Alias foropenDocumentFile
.
- Alias
-
Mirror
getDownloadCacheDirectory
fromEnvironment.getDataDirectory
. -
Mirror
getStorageDirectory
fromEnvironment.getStorageDirectory
.
Deprecation Notices #
getExternalStoragePublicDirectory
was 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.
0.2.0 #
Add basic support for Storage Access Framework
and targetSdk 31
.
- The package now supports basic intents from
Storage Access Framework
. - Your App needs update the
build.gradle
by targeting the current sdk to31
.
0.1.1 #
Minor improvements on pub.dev
documentation.
- Add
example/
folder. - Add missing
pubspec.yaml
properties.
0.1.0 #
Initial release.