yasukotelin / ext_storage Goto Github PK
View Code? Open in Web Editor NEWext_storage is minimal flutter plugin that provides external storage path and external public storage path.
License: MIT License
ext_storage is minimal flutter plugin that provides external storage path and external public storage path.
License: MIT License
How about directory for iOS.
In Android 10, the getExternalPublicStorage API will be deprecated, leading to an error when trying to get the paths.
Instead, methods like getExternalFilesDir() should now be used. Is it realistic for this package to include this change anytime soon?
Thank you so much for your great work!
Flutter Android V2 update
Howdy mate!
I just touched down into your repo and wanted to use the plugin for getting Storage paths. Although unfortunately I ran into build error at gradle stage. Attached is the stacktrace from Flutter.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\mhetr\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\ext_storage-1.0.3\android\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating project ':ext_storage'.
> Could not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* Where:
Script 'C:\Users\mhetr\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 326
* What went wrong:
A problem occurred configuring project ':ext_storage'.
> Failed to notify project evaluation listener.
> Could not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKt
> compileSdkVersion is not specified. Please add it to build.gradle
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I have no good idea of why this happened - being new at Flutter, but maybe you could help fix if plugin issue or give some resolution if an error from my side.
I've added ext_storage: ^1.0.3
to my project, did a flutter get and ran a debug session.
https://github.com/yasukotelin/ext_storage/blob/master/lib/ext_storage.dart#L33-L46
Instead of using Platform.isAndroid
to check if the current Platform is Android, I'm proposing the following solution:
import 'package:flutter/foundation.dart' show defaultTargetPlatform, TargetPlatform;
if (defaultTargetPlatform != TargetPlatform.android) {
throw UnsupportedError("Only android supported");
}
This will making widget testing with ext_storage easier because in tests, Platform.isAndroid always returns false. Whereas with defaultTargetPlatform != TargetPlatform.android
, a tester could use debugDefaultTargetPlatformOverride
to determine if the test environment is Android vs iOS:
testWidgets('test Android', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
// Insert Test Code Here
debugDefaultTargetPlatformOverride = null;
I can submit a PR for this if you would like.
Any planning to migrate to null-safety?
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: FileSystemException: Cannot open file, path = '/storage/emulated/0/Download/counter.txt' (OS Error: Permission denied, errno = 13)
Just Try Simple Code
void _example2() async {
var path = await ExtStorage.getExternalStoragePublicDirectory(ExtStorage.DIRECTORY_PICTURES);
print(path); // /storage/emulated/0/Pictures
}
Hello I'm using
ExtStorage.getExternalStoragePublicDirectory(ExtStorage.DIRECTORY_DOCUMENTS)
String fileDrc=await ExtStorage.getExternalStoragePublicDirectory(ExtStorage.DIRECTORY_DOCUMENTS);
final path= Directory( fileDrc+ "/Reports");
if (!(await path.exists()))
path.create();
but I get error
FileSystemException: Creation failed, path = '/storage/emulated/0/Documents/Reports' (OS Error: No such file or directory, errno = 2), stack trace: #0
Thanks for the plugin!
However, the string value for DIRECTORY_DOWNLOADS
is wrong, it should be Download
(without the s). This makes files created in this directory not show up in the default download folder.
"The plugins ext_storage use a deprecated version of the Android embedding"
How can i avoid this type of error ?
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.10 and higher.
The following dependencies do not satisfy the required version:
project ':ext_storage' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71
I'm using Android Studio 3.5 and gradle 3.5.1.
Change the ext.kotlin_version
to 1.3.10 and fixed the problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.