Commit 8f546a6c authored by zhouteng's avatar zhouteng

update sample code

parent 858342a4
......@@ -58,7 +58,9 @@ File f = await ImagePicker.pickVideo(
ShareExtend.share(f.path, "video");
//share file
Directory dir = await getApplicationDocumentsDirectory();
Directory dir = Platform.isAndroid
? await getExternalStorageDirectory()
: await getApplicationDocumentsDirectory();
File testFile = new File("${dir.path}/flutter/test.txt");
if (!await testFile.exists()) {
await testFile.create(recursive: true);
......
......@@ -55,7 +55,9 @@ File f = await ImagePicker.pickVideo(
ShareExtend.share(f.path, "video");
//分享文件
Directory dir = await getApplicationDocumentsDirectory();
Directory dir = Platform.isAndroid
? await getExternalStorageDirectory()
: await getApplicationDocumentsDirectory();
File testFile = new File("${dir.path}/flutter/test.txt");
if (!await testFile.exists()) {
await testFile.create(recursive: true);
......
......@@ -65,7 +65,7 @@ class _MyAppState extends State<MyApp> {
),
RaisedButton(
onPressed: () {
_shareApplicationDocumentsFile();
_shareStorageFile();
},
child: Text("share file"),
),
......@@ -106,9 +106,11 @@ class _MyAppState extends State<MyApp> {
return imageFile.path;
}
///share the documents file
_shareApplicationDocumentsFile() async {
Directory dir = await getApplicationDocumentsDirectory();
///share the storage file
_shareStorageFile() async {
Directory dir = Platform.isAndroid
? await getExternalStorageDirectory()
: await getApplicationDocumentsDirectory();
File testFile = File("${dir.path}/flutter/test.txt");
if (!await testFile.exists()) {
await testFile.create(recursive: true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment