Commit 8f546a6c authored by zhouteng's avatar zhouteng

update sample code

parent 858342a4
...@@ -58,7 +58,9 @@ File f = await ImagePicker.pickVideo( ...@@ -58,7 +58,9 @@ File f = await ImagePicker.pickVideo(
ShareExtend.share(f.path, "video"); ShareExtend.share(f.path, "video");
//share file //share file
Directory dir = await getApplicationDocumentsDirectory(); Directory dir = Platform.isAndroid
? await getExternalStorageDirectory()
: await getApplicationDocumentsDirectory();
File testFile = new File("${dir.path}/flutter/test.txt"); File testFile = new File("${dir.path}/flutter/test.txt");
if (!await testFile.exists()) { if (!await testFile.exists()) {
await testFile.create(recursive: true); await testFile.create(recursive: true);
......
...@@ -55,7 +55,9 @@ File f = await ImagePicker.pickVideo( ...@@ -55,7 +55,9 @@ File f = await ImagePicker.pickVideo(
ShareExtend.share(f.path, "video"); 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"); File testFile = new File("${dir.path}/flutter/test.txt");
if (!await testFile.exists()) { if (!await testFile.exists()) {
await testFile.create(recursive: true); await testFile.create(recursive: true);
......
...@@ -65,7 +65,7 @@ class _MyAppState extends State<MyApp> { ...@@ -65,7 +65,7 @@ class _MyAppState extends State<MyApp> {
), ),
RaisedButton( RaisedButton(
onPressed: () { onPressed: () {
_shareApplicationDocumentsFile(); _shareStorageFile();
}, },
child: Text("share file"), child: Text("share file"),
), ),
...@@ -106,9 +106,11 @@ class _MyAppState extends State<MyApp> { ...@@ -106,9 +106,11 @@ class _MyAppState extends State<MyApp> {
return imageFile.path; return imageFile.path;
} }
///share the documents file ///share the storage file
_shareApplicationDocumentsFile() async { _shareStorageFile() async {
Directory dir = await getApplicationDocumentsDirectory(); Directory dir = Platform.isAndroid
? await getExternalStorageDirectory()
: await getApplicationDocumentsDirectory();
File testFile = File("${dir.path}/flutter/test.txt"); File testFile = File("${dir.path}/flutter/test.txt");
if (!await testFile.exists()) { if (!await testFile.exists()) {
await testFile.create(recursive: true); 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