Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

collinjackson
Copy link
Contributor

@collinjackson collinjackson commented May 3, 2019

Fixes flutter/flutter#13474

This allows developers to store files that aren't user-generated in the correct folder on iOS.

Also updated the documentation:

  1. push devs towards using getStorageDirectory on Android when storing user-generated content that should be visible to the user.
  2. encourage the use of getTemporaryDirectory for storing caches of files that don't need to be backed up.

See https://developer.apple.com/icloud/documentation/data-storage/index.html

/cc @sroddy

@collinjackson collinjackson changed the title ## Description [path_provider] updates May 3, 2019
@collinjackson collinjackson changed the title [path_provider] updates [path_provider] updates to add ApplicationSupportLibrary May 3, 2019
@collinjackson collinjackson requested a review from mklim May 4, 2019 00:14
@collinjackson collinjackson changed the title [path_provider] updates to add ApplicationSupportLibrary [path_provider] updates to add getApplicationDocumentsDirectory May 4, 2019
@collinjackson collinjackson changed the title [path_provider] updates to add getApplicationDocumentsDirectory [path_provider] add getApplicationSupportDirectory May 4, 2019
@collinjackson
Copy link
Contributor Author

collinjackson commented May 6, 2019

It looks like the application support directory isn't automatically created.

I'm debating whether to create it automagically, but perhaps it is best to just return the path.

@mklim do you have any opinions?

Copy link
Contributor

@mklim mklim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm debating whether to create it automagically, but perhaps it is best to just return the path.

@mklim do you have any opinions?

I think it would be nice to create it automagically on the platform side. I wouldn't want to block for two async calls through the MethodChannel and back to check if it exists and then make it if it doesn't every time though.

/// use this directory for user data files.
///
/// On iOS, this uses the `NSApplicationSupportDirectory` API.
/// This directory is not guaranteed to exist and you can call `createSync` to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
/// This directory is not guaranteed to exist and you can call `createSync` to
/// This directory is not guaranteed to exist. You can call `createSync` to

@collinjackson
Copy link
Contributor Author

Review feedback addressed, PTAL

Copy link
Contributor

@mklim mklim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@collinjackson collinjackson merged commit a7c074c into flutter:master May 8, 2019
@collinjackson collinjackson deleted the pathprovider2 branch May 8, 2019 23:09
@nrkramer
Copy link

nrkramer commented Aug 19, 2019

@collinjackson
As an update:

String databasePath = '${(await getApplicationSupportDirectory()).path}/likedMovies.db'; print(databasePath);

This works on Android and returns a path:
'/data/user/0/apps.blanket.showtap/files'

Yet still throws an exception:
E/MethodChannel#plugins.flutter.io/path_provider(18577): Failed to handle method call
E/MethodChannel#plugins.flutter.io/path_provider(18577): java.lang.IllegalStateException: Reply already submitted
E/MethodChannel#plugins.flutter.io/path_provider(18577): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:135)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.notImplemented(MethodChannel.java:235)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at io.flutter.plugins.pathprovider.PathProviderPlugin.onMethodCall(PathProviderPlugin.java:44)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.flutter.io/path_provider(18577): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/DartMessenger(18577): Uncaught exception in binary message listener
E/DartMessenger(18577): java.lang.IllegalStateException: Reply already submitted
E/DartMessenger(18577): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:135)
E/DartMessenger(18577): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:240)
E/DartMessenger(18577): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/DartMessenger(18577): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/DartMessenger(18577): at android.os.MessageQueue.nativePollOnce(Native Method)
E/DartMessenger(18577): at android.os.MessageQueue.next(MessageQueue.java:326)
E/DartMessenger(18577): at android.os.Looper.loop(Looper.java:160)
E/DartMessenger(18577): at android.app.ActivityThread.main(ActivityThread.java:6669)
E/DartMessenger(18577): at java.lang.reflect.Method.invoke(Native Method)
E/DartMessenger(18577): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/DartMessenger(18577): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
This should have been landed as part of the previous flutter_tools PR.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PathProvider should provide a way to access the Library directory
4 participants