File tree 3 files changed +11
-6
lines changed
android/src/main/kotlin/io/lakscastro/sharedstorage/saf
lib/src/storage_access_framework 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import android.os.Build
6
6
import android.provider.DocumentsContract
7
7
import android.util.Log
8
8
import androidx.annotation.RequiresApi
9
+ import androidx.documentfile.provider.DocumentFile
9
10
import io.flutter.plugin.common.*
10
11
import io.flutter.plugin.common.EventChannel.StreamHandler
11
12
import io.lakscastro.sharedstorage.ROOT_CHANNEL
@@ -15,6 +16,7 @@ import io.lakscastro.sharedstorage.saf.utils.*
15
16
import kotlinx.coroutines.CoroutineScope
16
17
import kotlinx.coroutines.Dispatchers
17
18
import kotlinx.coroutines.launch
19
+ import java.io.File
18
20
19
21
internal class DocumentFileApi (private val plugin : SharedStoragePlugin ) :
20
22
MethodChannel .MethodCallHandler ,
@@ -173,8 +175,7 @@ internal class DocumentFileApi(private val plugin: SharedStoragePlugin) :
173
175
val uri = call.argument<String >(" uri" )!!
174
176
val parent = documentFromTreeUri(plugin.context, uri)?.parentFile
175
177
176
- if (parent != null )
177
- result.success(createDocumentFileMap(parent))
178
+ result.success(if (parent != null ) createDocumentFileMap(parent) else null )
178
179
}
179
180
}
180
181
else -> result.notImplemented()
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ class _FileTileState extends State<FileTile> {
117
117
height: _size.height,
118
118
);
119
119
120
- if (bitmap == null ) return ;
120
+ if (bitmap == null || ! mounted ) return ;
121
121
122
122
setState (() => imageBytes = bitmap.bytes);
123
123
}
Original file line number Diff line number Diff line change @@ -12,14 +12,18 @@ import 'package:shared_storage/src/storage_access_framework/uri_permission.dart'
12
12
///
13
13
/// [Refer to details] (https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT_TREE)
14
14
///
15
- /// TODO: Implement [initialDir] param to
16
15
/// support the initial directory of the directory picker
17
- Future <Uri ?> openDocumentTree ({bool grantWritePermission = true }) async {
16
+ Future <Uri ?> openDocumentTree (
17
+ {bool grantWritePermission = true , Uri ? initialUri}) async {
18
18
const kOpenDocumentTree = 'openDocumentTree' ;
19
19
20
20
const kGrantWritePermission = 'grantWritePermission' ;
21
+ const kInitialUri = 'initialUri' ;
21
22
22
- final args = < String , dynamic > {kGrantWritePermission: grantWritePermission};
23
+ final args = < String , dynamic > {
24
+ kGrantWritePermission: grantWritePermission,
25
+ kInitialUri: '$initialUri '
26
+ };
23
27
24
28
final selectedDirectoryUri =
25
29
await kDocumentFileChannel.invokeMethod <String ?>(kOpenDocumentTree, args);
You can’t perform that action at this time.
0 commit comments