changed open_file to open_filex fort (fixed some issues maybe)
This commit is contained in:
parent
3a44a2f9bc
commit
f533c5d4f5
@ -9,16 +9,20 @@ import 'package:filcnaplo_kreta_api/client/client.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/attachment.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/homework.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:open_file/open_file.dart';
|
||||
import 'package:open_filex/open_filex.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
extension AttachmentHelper on Attachment {
|
||||
Future<String> download(BuildContext context, {bool overwrite = false}) async {
|
||||
Future<String> download(BuildContext context,
|
||||
{bool overwrite = false}) async {
|
||||
String downloads = await StorageHelper.downloadsPath();
|
||||
|
||||
if (!overwrite && await File("$downloads/$name").exists()) return "$downloads/$name";
|
||||
if (!overwrite && await File("$downloads/$name").exists()) {
|
||||
return "$downloads/$name";
|
||||
}
|
||||
|
||||
Uint8List data = await Provider.of<KretaClient>(context, listen: false).getAPI(downloadUrl, rawResponse: true);
|
||||
Uint8List data = await Provider.of<KretaClient>(context, listen: false)
|
||||
.getAPI(downloadUrl, rawResponse: true);
|
||||
if (!await StorageHelper.write("$downloads/$name", data)) return "";
|
||||
|
||||
return "$downloads/$name";
|
||||
@ -28,19 +32,24 @@ extension AttachmentHelper on Attachment {
|
||||
String downloads = await StorageHelper.downloadsPath();
|
||||
|
||||
if (!await File("$downloads/$name").exists()) await download(context);
|
||||
var result = await OpenFile.open("$downloads/$name");
|
||||
var result = await OpenFilex.open("$downloads/$name");
|
||||
return result.type == ResultType.done;
|
||||
}
|
||||
}
|
||||
|
||||
extension HomeworkAttachmentHelper on HomeworkAttachment {
|
||||
Future<String> download(BuildContext context, {bool overwrite = false}) async {
|
||||
Future<String> download(BuildContext context,
|
||||
{bool overwrite = false}) async {
|
||||
String downloads = await StorageHelper.downloadsPath();
|
||||
|
||||
if (!overwrite && await File("$downloads/$name").exists()) return "$downloads/$name";
|
||||
if (!overwrite && await File("$downloads/$name").exists()) {
|
||||
return "$downloads/$name";
|
||||
}
|
||||
|
||||
String url = downloadUrl(Provider.of<UserProvider>(context, listen: false).instituteCode ?? "");
|
||||
Uint8List data = await Provider.of<KretaClient>(context, listen: false).getAPI(url, rawResponse: true);
|
||||
String url = downloadUrl(
|
||||
Provider.of<UserProvider>(context, listen: false).instituteCode ?? "");
|
||||
Uint8List data = await Provider.of<KretaClient>(context, listen: false)
|
||||
.getAPI(url, rawResponse: true);
|
||||
if (!await StorageHelper.write("$downloads/$name", data)) return "";
|
||||
|
||||
return "$downloads/$name";
|
||||
@ -50,7 +59,7 @@ extension HomeworkAttachmentHelper on HomeworkAttachment {
|
||||
String downloads = await StorageHelper.downloadsPath();
|
||||
|
||||
if (!await File("$downloads/$name").exists()) await download(context);
|
||||
var result = await OpenFile.open("$downloads/$name");
|
||||
var result = await OpenFilex.open("$downloads/$name");
|
||||
return result.type == ResultType.done;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import 'dart:typed_data';
|
||||
import 'package:filcnaplo/api/client.dart';
|
||||
import 'package:filcnaplo/helpers/storage_helper.dart';
|
||||
import 'package:filcnaplo/models/release.dart';
|
||||
import 'package:open_file/open_file.dart';
|
||||
import 'package:open_filex/open_filex.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
enum UpdateState { none, preparing, downloading, installing }
|
||||
@ -37,7 +37,7 @@ extension UpdateHelper on Release {
|
||||
(await Permission.manageExternalStorage.request().isGranted &&
|
||||
await Permission.requestInstallPackages.request().isGranted);
|
||||
if (installPerms) {
|
||||
var result = await OpenFile.open(apk.path);
|
||||
var result = await OpenFilex.open(apk.path);
|
||||
|
||||
if (result.type != ResultType.done) {
|
||||
// ignore: avoid_print
|
||||
|
@ -32,10 +32,11 @@ dependencies:
|
||||
http: ^0.13.3
|
||||
uuid: ^4.2.1
|
||||
html: ^0.15.0
|
||||
open_file:
|
||||
git:
|
||||
url: https://github.com/crazecoder/open_file
|
||||
ref: master
|
||||
open_filex: ^4.3.4
|
||||
# open_file:
|
||||
# git:
|
||||
# url: https://github.com/crazecoder/open_file
|
||||
# ref: master
|
||||
path_provider: ^2.0.2
|
||||
permission_handler: ^11.0.1
|
||||
share_plus: ^7.0.2
|
||||
|
Loading…
x
Reference in New Issue
Block a user