use correct folder on android platform
This commit is contained in:
parent
a80b547656
commit
2ba9fb3fbd
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gallery/data_provider/data_provider.dart';
|
import 'package:gallery/data_provider/data_provider.dart';
|
||||||
import 'package:gallery/image_grid.dart';
|
import 'package:gallery/image_grid.dart';
|
||||||
@ -20,23 +22,28 @@ enum Page { local, remote }
|
|||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
Page page = Page.local;
|
Page page = Page.local;
|
||||||
|
|
||||||
final DataProvider localProvider = LocalDataProvider(getApplicationDocumentsDirectory());
|
Future<Directory> _getLocalDir() async {
|
||||||
|
Directory dir;
|
||||||
|
if (Theme.of(context).platform == TargetPlatform.android) {
|
||||||
|
dir = Directory("/storage/emulated/0/DCIM/");
|
||||||
|
} else {
|
||||||
|
dir = (await getDownloadsDirectory())?.parent ??
|
||||||
|
await getApplicationDocumentsDirectory();
|
||||||
|
}
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildPage() {
|
Widget _buildPage() {
|
||||||
DataProvider provider;
|
DataProvider provider;
|
||||||
|
|
||||||
switch (page) {
|
switch (page) {
|
||||||
case Page.local:
|
case Page.local:
|
||||||
provider = localProvider;
|
provider = LocalDataProvider(_getLocalDir());
|
||||||
break;
|
break;
|
||||||
case Page.remote:
|
case Page.remote:
|
||||||
// todo do not generate a new provider on each tab switch
|
// todo do not generate a new provider on each tab switch
|
||||||
provider = SSHDataProvider(
|
provider = SSHDataProvider(
|
||||||
initialPath: "/",
|
initialPath: "/", host: "", password: "", port: 0, username: "");
|
||||||
host: "",
|
|
||||||
password: "",
|
|
||||||
port: 0,
|
|
||||||
username: "");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ImageGrid(dProvider: provider);
|
return ImageGrid(dProvider: provider);
|
||||||
|
Loading…
Reference in New Issue
Block a user