chore: Follow up download android

This commit is contained in:
Krille 2023-03-19 09:01:14 +01:00
parent 57618417a1
commit df91290a18
No known key found for this signature in database

View File

@ -1,3 +1,4 @@
import 'dart:developer';
import 'dart:io';
import 'package:flutter/material.dart';
@ -49,14 +50,19 @@ extension MatrixFileExtension on MatrixFile {
}
Future<String> getDownloadPathAndroid() async {
final directory = await getDownloadDirectoryAndroid();
return '${directory.path}/$name';
}
Future<Directory> getDownloadDirectoryAndroid() async {
final downloadDirectories = await getExternalStorageDirectories(
type: StorageDirectory.downloads,
);
if (downloadDirectories != null && downloadDirectories.isNotEmpty) {
return downloadDirectories.first.path;
inspect(downloadDirectories);
return downloadDirectories.first;
}
final fallbackDirectory = await getApplicationDocumentsDirectory();
return fallbackDirectory.path;
return await getApplicationDocumentsDirectory();
}
FileType get filePickerFileType {