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:gallery/data_provider/data_provider.dart';
|
||||
import 'package:gallery/image_grid.dart';
|
||||
@ -20,23 +22,28 @@ enum Page { local, remote }
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
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() {
|
||||
DataProvider provider;
|
||||
|
||||
switch (page) {
|
||||
case Page.local:
|
||||
provider = localProvider;
|
||||
provider = LocalDataProvider(_getLocalDir());
|
||||
break;
|
||||
case Page.remote:
|
||||
// todo do not generate a new provider on each tab switch
|
||||
provider = SSHDataProvider(
|
||||
initialPath: "/",
|
||||
host: "",
|
||||
password: "",
|
||||
port: 0,
|
||||
username: "");
|
||||
initialPath: "/", host: "", password: "", port: 0, username: "");
|
||||
break;
|
||||
}
|
||||
return ImageGrid(dProvider: provider);
|
||||
|
Loading…
Reference in New Issue
Block a user