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

Commit 1ed46af

Browse files
authored
Add path_provider plugin (#12)
1 parent aa929a9 commit 1ed46af

File tree

79 files changed

+2695
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2695
-0
lines changed

packages/path-provider/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
.atom/
3+
.idea
4+
.packages
5+
.pub/
6+
build/
7+
ios/.generated/
8+
packages
9+
pubspec.lock
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## [0.1.0] - 2017-05-03
2+
3+
* Initial Open Source release.

packages/path-provider/LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright 2017, the Flutter project authors. All rights reserved.
2+
Redistribution and use in source and binary forms, with or without
3+
modification, are permitted provided that the following conditions are
4+
met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/path-provider/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# path_provider
2+
3+
Flutter plugin for finding commonly used locations on the filesystem. Supports iOS and Android.
4+
5+
6+
## Usage
7+
8+
To use this plugin, add path_provider as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).
9+
10+
11+
### Example
12+
After importing ```'package:path_provider/path_provider.dart'``` the directories can be queried as follows
13+
14+
``` dart
15+
Directory tempDir = await getTemporaryDirectory();
16+
String tempPath = tempDir.path;
17+
18+
Directory appDocDir = await getApplicationDocumentsDirectory();
19+
String appDocPath = appDocDir.path;
20+
```
21+
Please see the example app of this plugin for a full example.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
10+
/gradle
11+
/gradlew
12+
/gradlew.bat
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
group 'io.flutter.plugins.path_provider'
2+
version '1.0-SNAPSHOT'
3+
4+
buildscript {
5+
repositories {
6+
jcenter()
7+
}
8+
9+
dependencies {
10+
classpath 'com.android.tools.build:gradle:2.3.0'
11+
}
12+
}
13+
14+
allprojects {
15+
repositories {
16+
jcenter()
17+
}
18+
}
19+
20+
apply plugin: 'com.android.library'
21+
22+
android {
23+
compileSdkVersion 25
24+
buildToolsVersion '25.0.0'
25+
26+
defaultConfig {
27+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
28+
}
29+
lintOptions {
30+
disable 'InvalidPackage'
31+
}
32+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs=-Xmx1536M
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'path_provider'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="io.flutter.plugins.path_provider"
3+
android:versionCode="1"
4+
android:versionName="0.0.1">
5+
6+
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
7+
</manifest>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins.path_provider;
6+
7+
import io.flutter.app.FlutterActivity;
8+
import io.flutter.plugin.common.MethodChannel;
9+
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
10+
import io.flutter.plugin.common.MethodChannel.Result;
11+
import io.flutter.plugin.common.MethodCall;
12+
import io.flutter.util.PathUtils;
13+
14+
15+
public class PathProviderPlugin implements MethodCallHandler {
16+
private FlutterActivity activity;
17+
18+
public static PathProviderPlugin register(FlutterActivity activity) {
19+
return new PathProviderPlugin(activity);
20+
}
21+
22+
private PathProviderPlugin(FlutterActivity activity) {
23+
this.activity = activity;
24+
new MethodChannel(activity.getFlutterView(), "plugins.flutter.io/path_provider").
25+
setMethodCallHandler(this);
26+
}
27+
28+
@Override
29+
public void onMethodCall(MethodCall call, Result result) {
30+
switch (call.method) {
31+
case "getTemporaryDirectory":
32+
result.success(getPathProviderTemporaryDirectory());
33+
break;
34+
case "getApplicationDocumentsDirectory":
35+
result.success(getPathProviderApplicationDocumentsDirectory());
36+
break;
37+
default:
38+
result.notImplemented();
39+
}
40+
}
41+
42+
private String getPathProviderTemporaryDirectory() {
43+
return activity.getCacheDir().getPath();
44+
}
45+
46+
private String getPathProviderApplicationDocumentsDirectory() {
47+
return PathUtils.getDataDirectory(activity);
48+
}
49+
}

0 commit comments

Comments
 (0)