Commit 19e6df9daf547685223cbbcf098f6b6742b3ac62

Authored by wdn127929
2 parents c7967a90 f47924ea

下载excel dio

@@ -22,6 +22,8 @@ def flutterVersionCode = "519" @@ -22,6 +22,8 @@ def flutterVersionCode = "519"
22 if (flutterVersionCode == null) { 22 if (flutterVersionCode == null) {
23 flutterVersionCode = '519' 23 flutterVersionCode = '519'
24 24
  25 +
  26 +
25 } 27 }
26 28
27 29
@@ -50,6 +50,8 @@ @@ -50,6 +50,8 @@
50 android:name="flutterEmbedding" 50 android:name="flutterEmbedding"
51 android:value="2" /> 51 android:value="2" />
52 52
  53 +
  54 +
53 <intent-filter> 55 <intent-filter>
54 <action android:name="android.intent.action.MAIN"/> 56 <action android:name="android.intent.action.MAIN"/>
55 <category android:name="android.intent.category.LAUNCHER"/> 57 <category android:name="android.intent.category.LAUNCHER"/>
@@ -108,6 +110,18 @@ @@ -108,6 +110,18 @@
108 android:value="5" /> 110 android:value="5" />
109 </provider> 111 </provider>
110 <!-- End FlutterDownloader customization --> 112 <!-- End FlutterDownloader customization -->
  113 +
  114 + <provider
  115 + android:name="androidx.core.content.FileProvider"
  116 + android:authorities="${applicationId}.fileProvider"
  117 + android:exported="false"
  118 + android:grantUriPermissions="true"
  119 + tools:replace="android:authorities">
  120 + <meta-data
  121 + android:name="android.support.FILE_PROVIDER_PATHS"
  122 + android:resource="@xml/filepaths"
  123 + tools:replace="android:resource" />
  124 + </provider>
111 <meta-data 125 <meta-data
112 android:name="com.amap.api.v2.apikey" 126 android:name="com.amap.api.v2.apikey"
113 android:value="13464ddadd6a5d825e79f90e10ba72d2"/> 127 android:value="13464ddadd6a5d825e79f90e10ba72d2"/>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <string name="flutter_downloader_notification_started">开始下载</string>
  4 + <string name="flutter_downloader_notification_in_progress">下载中</string>
  5 + <string name="flutter_downloader_notification_canceled">取消下载</string>
  6 + <string name="flutter_downloader_notification_failed">下载失败</string>
  7 + <string name="flutter_downloader_notification_complete">下载完成</string>
  8 + <string name="flutter_downloader_notification_paused">暂停</string>
  9 + <string name="flutter_downloader_notification_channel_name">Downloader</string>
  10 + <string name="flutter_downloader_notification_channel_description">Display download progress</string>
  11 +</resources>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <external-path name="external_storage_directory" path="." />
  4 +</resources>
@@ -60,6 +60,17 @@ subprojects { @@ -60,6 +60,17 @@ subprojects {
60 project.evaluationDependsOn(':app') 60 project.evaluationDependsOn(':app')
61 } 61 }
62 62
  63 +subprojects {
  64 + project.configurations.all {
  65 + resolutionStrategy.eachDependency { details ->
  66 + if (details.requested.group == 'com.android.support'
  67 + && !details.requested.name.contains('multidex') ) {
  68 + details.useVersion "27.1.1"
  69 + }
  70 + }
  71 + }
  72 +}
  73 +
63 task clean(type: Delete) { 74 task clean(type: Delete) {
64 delete rootProject.buildDir 75 delete rootProject.buildDir
65 } 76 }
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 archiveVersion = 1; 3 archiveVersion = 1;
4 classes = { 4 classes = {
5 }; 5 };
6 - objectVersion = 46; 6 + objectVersion = 50;
7 objects = { 7 objects = {
8 8
9 /* Begin PBXBuildFile section */ 9 /* Begin PBXBuildFile section */
@@ -538,7 +538,7 @@ @@ -538,7 +538,7 @@
538 CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements; 538 CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
539 CODE_SIGN_IDENTITY = "Apple Development"; 539 CODE_SIGN_IDENTITY = "Apple Development";
540 CODE_SIGN_STYLE = Automatic; 540 CODE_SIGN_STYLE = Automatic;
541 - CURRENT_PROJECT_VERSION = 5182; 541 + CURRENT_PROJECT_VERSION = 519;
542 DEVELOPMENT_TEAM = 8J59HM8B82; 542 DEVELOPMENT_TEAM = 8J59HM8B82;
543 ENABLE_BITCODE = NO; 543 ENABLE_BITCODE = NO;
544 FLUTTER_BUILD_MODE = release; 544 FLUTTER_BUILD_MODE = release;
@@ -553,7 +553,7 @@ @@ -553,7 +553,7 @@
553 "$(inherited)", 553 "$(inherited)",
554 "$(PROJECT_DIR)/Flutter", 554 "$(PROJECT_DIR)/Flutter",
555 ); 555 );
556 - MARKETING_VERSION = 5.1.8; 556 + MARKETING_VERSION = 5.1.9;
557 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 557 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
558 PRODUCT_NAME = Runner; 558 PRODUCT_NAME = Runner;
559 PROVISIONING_PROFILE_SPECIFIER = ""; 559 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -684,7 +684,7 @@ @@ -684,7 +684,7 @@
684 CODE_SIGN_ENTITLEMENTS = "Runner/一键订Debug.entitlements"; 684 CODE_SIGN_ENTITLEMENTS = "Runner/一键订Debug.entitlements";
685 CODE_SIGN_IDENTITY = "Apple Development"; 685 CODE_SIGN_IDENTITY = "Apple Development";
686 CODE_SIGN_STYLE = Automatic; 686 CODE_SIGN_STYLE = Automatic;
687 - CURRENT_PROJECT_VERSION = 5182; 687 + CURRENT_PROJECT_VERSION = 519;
688 DEVELOPMENT_TEAM = 8J59HM8B82; 688 DEVELOPMENT_TEAM = 8J59HM8B82;
689 ENABLE_BITCODE = NO; 689 ENABLE_BITCODE = NO;
690 FLUTTER_BUILD_MODE = release; 690 FLUTTER_BUILD_MODE = release;
@@ -699,7 +699,7 @@ @@ -699,7 +699,7 @@
699 "$(inherited)", 699 "$(inherited)",
700 "$(PROJECT_DIR)/Flutter", 700 "$(PROJECT_DIR)/Flutter",
701 ); 701 );
702 - MARKETING_VERSION = 5.1.8; 702 + MARKETING_VERSION = 5.1.9;
703 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 703 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
704 PRODUCT_NAME = Runner; 704 PRODUCT_NAME = Runner;
705 PROVISIONING_PROFILE_SPECIFIER = ""; 705 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -720,7 +720,7 @@ @@ -720,7 +720,7 @@
720 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 720 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
721 CODE_SIGN_IDENTITY = "Apple Development"; 721 CODE_SIGN_IDENTITY = "Apple Development";
722 CODE_SIGN_STYLE = Automatic; 722 CODE_SIGN_STYLE = Automatic;
723 - CURRENT_PROJECT_VERSION = 5182; 723 + CURRENT_PROJECT_VERSION = 519;
724 DEVELOPMENT_TEAM = 8J59HM8B82; 724 DEVELOPMENT_TEAM = 8J59HM8B82;
725 ENABLE_BITCODE = NO; 725 ENABLE_BITCODE = NO;
726 FLUTTER_BUILD_MODE = release; 726 FLUTTER_BUILD_MODE = release;
@@ -735,7 +735,7 @@ @@ -735,7 +735,7 @@
735 "$(inherited)", 735 "$(inherited)",
736 "$(PROJECT_DIR)/Flutter", 736 "$(PROJECT_DIR)/Flutter",
737 ); 737 );
738 - MARKETING_VERSION = 5.1.8; 738 + MARKETING_VERSION = 5.1.9;
739 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; 739 PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
740 PRODUCT_NAME = Runner; 740 PRODUCT_NAME = Runner;
741 PROVISIONING_PROFILE_SPECIFIER = ""; 741 PROVISIONING_PROFILE_SPECIFIER = "";
@@ -4,6 +4,7 @@ import 'dart:ui'; @@ -4,6 +4,7 @@ import 'dart:ui';
4 4
5 import 'package:common_utils/common_utils.dart'; 5 import 'package:common_utils/common_utils.dart';
6 import 'package:device_info/device_info.dart'; 6 import 'package:device_info/device_info.dart';
  7 +import 'package:dio/dio.dart';
7 import 'package:flutter/material.dart'; 8 import 'package:flutter/material.dart';
8 import 'package:flutter_picker/Picker.dart'; 9 import 'package:flutter_picker/Picker.dart';
9 import 'package:flutter_screenutil/flutter_screenutil.dart'; 10 import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -14,12 +15,14 @@ import 'package:one_key/widgets/v_empty_view.dart'; @@ -14,12 +15,14 @@ import 'package:one_key/widgets/v_empty_view.dart';
14 import 'package:path_provider/path_provider.dart'; 15 import 'package:path_provider/path_provider.dart';
15 import 'package:permission_handler/permission_handler.dart'; 16 import 'package:permission_handler/permission_handler.dart';
16 17
  18 +import '../../../../net/dio_util.dart';
17 import '../../../../utils/dialog_util.dart'; 19 import '../../../../utils/dialog_util.dart';
18 import '../../../../utils/screen_util.dart'; 20 import '../../../../utils/screen_util.dart';
19 import '../../../../utils/utils.dart'; 21 import '../../../../utils/utils.dart';
20 import '../../../../widgets/h_empty_view.dart'; 22 import '../../../../widgets/h_empty_view.dart';
21 import 'package:flutter_downloader/flutter_downloader.dart'; 23 import 'package:flutter_downloader/flutter_downloader.dart';
22 import 'package:android_path_provider/android_path_provider.dart'; 24 import 'package:android_path_provider/android_path_provider.dart';
  25 +import 'package:open_file/open_file.dart';
23 26
24 /** 27 /**
25 * 导出预订数据 28 * 导出预订数据
@@ -51,14 +54,130 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -51,14 +54,130 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
51 void initState() { 54 void initState() {
52 super.initState(); 55 super.initState();
53 56
54 - _bindBackgroundIsolate(); 57 + // IsolateNameServer.registerPortWithName(
  58 + // _port.sendPort, 'downloader_send_port');
  59 + // _port.listen((dynamic data) {
  60 + // taskId = data[0];
  61 + // status = DownloadTaskStatus(data[1]);
  62 + // progress = data[2];
  63 + // setState(() {});
  64 + // if (status == DownloadTaskStatus.undefined) {
  65 + // // _requestDownload(task);
  66 + // } else if (status == DownloadTaskStatus.running) {
  67 + // // _pauseDownload(task);
  68 + // // setState(() {});
  69 + // } else if (status == DownloadTaskStatus.paused) {
  70 + // // _resumeDownload(task);
  71 + // // setState(() {});
  72 + // } else if (status == DownloadTaskStatus.complete ||
  73 + // status == DownloadTaskStatus.canceled) {
  74 + // // _delete(task);
55 75
56 - FlutterDownloader.registerCallback(downloadCallback, step: 1); 76 + // // 显示是否打开的对话框
  77 +
  78 + // DialogUtil.cupertinoAlertDialog(context,
  79 + // title: '提示',
  80 + // content: '文件下载完成,是否打开?',
  81 + // lTitle: '取消',
  82 + // rTitle: '打开', lCallback: () {
  83 + // Navigator.pop(context);
  84 + // }, rCallback: () async {
  85 + // // Navigator.pop(context);
  86 +
  87 + // print(_localPath);
  88 +
  89 + // final tasks = await FlutterDownloader.loadTasks();
  90 + // String str = '';
  91 + // tasks.forEach((element) {
  92 + // str = element.savedDir + '/' + element.filename;
  93 + // });
  94 + // print(str);
  95 +
  96 + // if (str != '') {
  97 + // OpenFile.open(str);
  98 + // _delete();
  99 + // }
  100 + // });
  101 + // // showDialog(
  102 + // // // 设置点击 dialog 外部不取消 dialog,默认能够取消
  103 + // // barrierDismissible: false,
  104 + // // context: context,
  105 + // // builder: (context) => AlertDialog(
  106 + // // title: Text('提示'),
  107 + // // // 标题文字样式
  108 + // // content: Text('文件下载完成,是否打开?'),
  109 + // // // 内容文字样式
  110 + // // backgroundColor: MyColours.color_ffffff,
  111 + // // elevation: 8.0,
  112 + // // // 投影的阴影高度
  113 + // // semanticLabel: 'Label',
  114 + // // // 这个用于无障碍下弹出 dialog 的提示
  115 + // // shape: Border.all(),
  116 + // // // dialog 的操作按钮,actions 的个数尽量控制不要过多,否则会溢出 `Overflow`
  117 + // // actions: <Widget>[
  118 + // // // 点击取消按钮
  119 + // // InkWell(
  120 + // // onTap: () => Navigator.pop(context), child: Text('取消')),
  121 + // // // 点击打开按钮
  122 + // // InkWell(
  123 + // // onTap: () async {
  124 + // // Navigator.pop(context);
  125 +
  126 + // // print(_localPath);
  127 +
  128 + // // final tasks = await FlutterDownloader.loadTasks();
  129 + // // String str = '';
  130 + // // tasks.forEach((element) {
  131 + // // str = element.savedDir + '/' + element.filename;
  132 + // // });
  133 + // // print(str);
  134 + // // if (str != '') {
  135 + // // OpenFile.open(str);
  136 + // // }
  137 +
  138 + // // // 打开文件
  139 + // // // _openDownloadedFile(taskId).then((success) {
  140 + // // // if (!success) {
  141 + // // // Utils.showToast('Cannot open this file');
  142 + // // // // Scaffold.of(context).showSnackBar(SnackBar(
  143 + // // // // content: Text('Cannot open this file')));
  144 + // // // }
  145 + // // // });
  146 + // // },
  147 + // // child: Text('打开')),
  148 + // // ],
  149 + // // ));
  150 + // } else if (status == DownloadTaskStatus.failed) {
  151 + // // _retryDownload(task);
  152 + // Utils.showToast('下载异常,请稍后重试');
  153 + // }
  154 + // });
  155 +
  156 + // FlutterDownloader.registerCallback(downloadCallback);
  157 +
  158 + // // _bindBackgroundIsolate();
  159 +
  160 + // // FlutterDownloader.registerCallback(downloadCallback, step: 1);
  161 + // _delete();
57 } 162 }
58 163
  164 + // _preae() async {
  165 + // final tasks = await FlutterDownloader.loadTasks();
  166 +
  167 + // if (tasks == null) {
  168 + // print('No tasks were retrieved from the database.');
  169 + // return;
  170 + // } else {
  171 + // tasks.forEach((element) {
  172 + // FlutterDownloader.remove(
  173 + // taskId: element.taskId, shouldDeleteContent: false);
  174 + // });
  175 + // }
  176 + // }
  177 +
59 @override 178 @override
60 void dispose() { 179 void dispose() {
61 - _unbindBackgroundIsolate(); 180 + // _unbindBackgroundIsolate();
62 super.dispose(); 181 super.dispose();
63 } 182 }
64 183
@@ -68,13 +187,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -68,13 +187,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
68 int status, 187 int status,
69 int progress, 188 int progress,
70 ) { 189 ) {
71 - print(  
72 - 'Callback on background isolate: '  
73 - 'task ($id) is in status ($status) and process ($progress)',  
74 - );  
75 -  
76 - IsolateNameServer.lookupPortByName('downloader_send_port')  
77 - ?.send([id, status, progress]); 190 + final SendPort send =
  191 + IsolateNameServer.lookupPortByName('downloader_send_port');
  192 + send.send([id, status, progress]);
78 } 193 }
79 194
80 // 根据taskId打开下载文件 195 // 根据taskId打开下载文件
@@ -82,75 +197,89 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -82,75 +197,89 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
82 return FlutterDownloader.open(taskId: taskId); 197 return FlutterDownloader.open(taskId: taskId);
83 } 198 }
84 199
85 - void _bindBackgroundIsolate() {  
86 - final isSuccess = IsolateNameServer.registerPortWithName(  
87 - _port.sendPort,  
88 - 'downloader_send_port',  
89 - );  
90 - if (!isSuccess) {  
91 - _unbindBackgroundIsolate();  
92 - _bindBackgroundIsolate();  
93 - return; 200 + // void _bindBackgroundIsolate() {
  201 + // final isSuccess = IsolateNameServer.registerPortWithName(
  202 + // _port.sendPort,
  203 + // 'downloader_send_port',
  204 + // );
  205 + // if (!isSuccess) {
  206 + // _unbindBackgroundIsolate();
  207 + // _bindBackgroundIsolate();
  208 + // return;
  209 + // }
  210 + // _port.listen((dynamic data) {
  211 + // taskId = (data as List<dynamic>)[0] as String;
  212 + // status = DownloadTaskStatus(data[1] as int);
  213 + // progressT = data[2] as int;
  214 +
  215 + // print(
  216 + // 'Callback on UI isolate: '
  217 + // 'task ($taskId) is in status ($status) and process ($progressT)',
  218 + // );
  219 + // if (status == DownloadTaskStatus.undefined) {
  220 + // // _requestDownload(task);
  221 + // } else if (status == DownloadTaskStatus.running) {
  222 + // // _pauseDownload(task);
  223 + // setState(() {});
  224 + // } else if (status == DownloadTaskStatus.paused) {
  225 + // // _resumeDownload(task);
  226 + // setState(() {});
  227 + // } else if (status == DownloadTaskStatus.complete ||
  228 + // status == DownloadTaskStatus.canceled) {
  229 + // // _delete(task);
  230 + // // 显示是否打开的对话框
  231 + // showDialog(
  232 + // // 设置点击 dialog 外部不取消 dialog,默认能够取消
  233 + // barrierDismissible: false,
  234 + // context: context,
  235 + // builder: (context) => AlertDialog(
  236 + // title: Text('提示'),
  237 + // // 标题文字样式
  238 + // content: Text('文件下载完成,是否打开?'),
  239 + // // 内容文字样式
  240 + // backgroundColor: MyColours.color_ffffff,
  241 + // elevation: 8.0,
  242 + // // 投影的阴影高度
  243 + // semanticLabel: 'Label',
  244 + // // 这个用于无障碍下弹出 dialog 的提示
  245 + // shape: Border.all(),
  246 + // // dialog 的操作按钮,actions 的个数尽量控制不要过多,否则会溢出 `Overflow`
  247 + // actions: <Widget>[
  248 + // // 点击取消按钮
  249 + // InkWell(
  250 + // onTap: () => Navigator.pop(context), child: Text('取消')),
  251 + // // 点击打开按钮
  252 + // InkWell(
  253 + // onTap: () {
  254 + // Navigator.pop(context);
  255 + // // 打开文件
  256 + // _openDownloadedFile(taskId).then((success) {
  257 + // if (!success) {
  258 + // Utils.showToast('Cannot open this file');
  259 + // // Scaffold.of(context).showSnackBar(SnackBar(
  260 + // // content: Text('Cannot open this file')));
  261 + // }
  262 + // });
  263 + // },
  264 + // child: Text('打开')),
  265 + // ],
  266 + // ));
  267 + // } else if (status == DownloadTaskStatus.failed) {
  268 + // // _retryDownload(task);
  269 + // Utils.showToast('下载异常,请稍后重试');
  270 + // }
  271 + // });
  272 + // }
  273 + Future<void> _delete() async {
  274 + final task = await FlutterDownloader.loadTasks();
  275 + if (task != null) {
  276 + task.forEach((element) {
  277 + FlutterDownloader.remove(
  278 + taskId: element.taskId,
  279 + shouldDeleteContent: true,
  280 + );
  281 + });
94 } 282 }
95 - _port.listen((dynamic data) {  
96 - taskId = (data as List<dynamic>)[0] as String;  
97 - status = DownloadTaskStatus(data[1] as int);  
98 - progress = data[2] as int;  
99 -  
100 - print(  
101 - 'Callback on UI isolate: '  
102 - 'task ($taskId) is in status ($status) and process ($progress)',  
103 - );  
104 - if (status == DownloadTaskStatus.undefined) {  
105 - // _requestDownload(task);  
106 - } else if (status == DownloadTaskStatus.running) {  
107 - // _pauseDownload(task);  
108 - } else if (status == DownloadTaskStatus.paused) {  
109 - // _resumeDownload(task);  
110 - } else if (status == DownloadTaskStatus.complete ||  
111 - status == DownloadTaskStatus.canceled) {  
112 - // _delete(task);  
113 - // 显示是否打开的对话框  
114 - showDialog(  
115 - // 设置点击 dialog 外部不取消 dialog,默认能够取消  
116 - barrierDismissible: false,  
117 - context: context,  
118 - builder: (context) => AlertDialog(  
119 - title: Text('提示'),  
120 - // 标题文字样式  
121 - content: Text('文件下载完成,是否打开?'),  
122 - // 内容文字样式  
123 - backgroundColor: MyColours.color_ffffff,  
124 - elevation: 8.0,  
125 - // 投影的阴影高度  
126 - semanticLabel: 'Label',  
127 - // 这个用于无障碍下弹出 dialog 的提示  
128 - shape: Border.all(),  
129 - // dialog 的操作按钮,actions 的个数尽量控制不要过多,否则会溢出 `Overflow`  
130 - actions: <Widget>[  
131 - // 点击取消按钮  
132 - InkWell(  
133 - onTap: () => Navigator.pop(context), child: Text('取消')),  
134 - // 点击打开按钮  
135 - InkWell(  
136 - onTap: () {  
137 - Navigator.pop(context);  
138 - // 打开文件  
139 - _openDownloadedFile(taskId).then((success) {  
140 - if (!success) {  
141 - Utils.showToast('Cannot open this file');  
142 - // Scaffold.of(context).showSnackBar(SnackBar(  
143 - // content: Text('Cannot open this file')));  
144 - }  
145 - });  
146 - },  
147 - child: Text('打开')),  
148 - ],  
149 - ));  
150 - } else if (status == DownloadTaskStatus.failed) {  
151 - // _retryDownload(task);  
152 - }  
153 - });  
154 } 283 }
155 284
156 Future<void> _prepareSaveDir() async { 285 Future<void> _prepareSaveDir() async {
@@ -165,14 +294,14 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -165,14 +294,14 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
165 String externalStorageDirPath; 294 String externalStorageDirPath;
166 295
167 if (Platform.isAndroid) { 296 if (Platform.isAndroid) {
168 - try {  
169 - externalStorageDirPath = await AndroidPathProvider.downloadsPath;  
170 - } catch (err, st) {  
171 - print('failed to get downloads path: $err, $st'); 297 + // try {
  298 + // externalStorageDirPath = await AndroidPathProvider.downloadsPath;
  299 + // } catch (err, st) {
  300 + // print('failed to get downloads path: $err, $st');
172 301
173 - final directory = await getExternalStorageDirectory();  
174 - externalStorageDirPath = directory?.path;  
175 - } 302 + final directory = await getExternalStorageDirectory();
  303 + externalStorageDirPath = directory?.path;
  304 + // }
176 } else if (Platform.isIOS) { 305 } else if (Platform.isIOS) {
177 externalStorageDirPath = 306 externalStorageDirPath =
178 (await getApplicationDocumentsDirectory()).absolute.path; 307 (await getApplicationDocumentsDirectory()).absolute.path;
@@ -186,10 +315,10 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -186,10 +315,10 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
186 } 315 }
187 316
188 if (Platform.isAndroid) { 317 if (Platform.isAndroid) {
189 - final info = await DeviceInfoPlugin().androidInfo;  
190 - if (info.version.sdkInt > 28) {  
191 - return true;  
192 - } 318 + // final info = await DeviceInfoPlugin().androidInfo;
  319 + // if (info.version.sdkInt > 28) {
  320 + // return true;
  321 + // }
193 322
194 final status = await Permission.storage.status; 323 final status = await Permission.storage.status;
195 if (status == PermissionStatus.granted) { 324 if (status == PermissionStatus.granted) {
@@ -299,8 +428,14 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -299,8 +428,14 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
299 // controller: controller, 428 // controller: controller,
300 child: Column( 429 child: Column(
301 children: [ 430 children: [
302 - (status == DownloadTaskStatus.running ||  
303 - status == DownloadTaskStatus.paused) 431 + // (status == DownloadTaskStatus.running ||
  432 + // status == DownloadTaskStatus.paused)
  433 + // ? LinearProgressIndicator(
  434 + // value: progress / 100,
  435 + // )
  436 + // : VEmptyView(10),
  437 +
  438 + progress != null && progress != 100
304 ? LinearProgressIndicator( 439 ? LinearProgressIndicator(
305 value: progress / 100, 440 value: progress / 100,
306 ) 441 )
@@ -404,7 +539,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -404,7 +539,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
404 ), 539 ),
405 VEmptyView(26), 540 VEmptyView(26),
406 RoundButton( 541 RoundButton(
407 - text: '导出数据', 542 + text: (progress != null && progress != 100)
  543 + ? '${progress}%'
  544 + : '导出数据',
408 width: w(218), 545 width: w(218),
409 height: w(43), 546 height: w(43),
410 gradientStart: MyColours.color_f3f3f3, 547 gradientStart: MyColours.color_f3f3f3,
@@ -415,22 +552,86 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -415,22 +552,86 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
415 fontSize: 32, 552 fontSize: 32,
416 isBold: true, 553 isBold: true,
417 onPressed: () async { 554 onPressed: () async {
  555 + if (progress != null) {
  556 + return;
  557 + }
  558 +
418 bool _permissionReady = await _checkPermission(); 559 bool _permissionReady = await _checkPermission();
419 if (_permissionReady) { 560 if (_permissionReady) {
420 await _prepareSaveDir(); 561 await _prepareSaveDir();
421 } 562 }
422 - taskId = await FlutterDownloader.enqueue(  
423 - url: 563 + // _delete();
  564 + String savePath = _localPath + "/fff.pdf";
  565 + Directory directory = new Directory(savePath);
  566 + if (directory.existsSync()) {
  567 + //删除历史
  568 + final List<FileSystemEntity> files = directory.listSync();
  569 + for (FileSystemEntity file in files) {
  570 + file.deleteSync();
  571 + }
  572 + }
  573 +
  574 + try {
  575 + Response response = await DioUtil().download(
424 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf', 576 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
425 - headers: {  
426 - 'auth': 'test_for_sql_encoding'  
427 - }, // optional: header send with url (auth token etc)  
428 - savedDir: _localPath,  
429 - showNotification:  
430 - true, // show download progress in status bar (for Android)  
431 - openFileFromNotification:  
432 - true, // click on notification to open downloaded file (for Android)  
433 - ); 577 + savePath, onProgress: (received, total) {
  578 + if (progress != 100) {
  579 + progress = ((received / total) * 100).round();
  580 +
  581 + setState(() {});
  582 + }
  583 + if (received == total) {
  584 + //下载完成
  585 + print('xaizaiwancheng');
  586 +
  587 + DialogUtil.cupertinoAlertDialog(context,
  588 + title: '提示',
  589 + content: '文件下载完成,是否打开?',
  590 + lTitle: '取消',
  591 + rTitle: '打开', lCallback: () {
  592 + progress = null;
  593 + setState(() {});
  594 + }, rCallback: () async {
  595 + // Navigator.pop(context);
  596 +
  597 + // print(_localPath);
  598 +
  599 + // final tasks = await FlutterDownloader.loadTasks();
  600 + // String str = '';
  601 + // tasks.forEach((element) {
  602 + // str = element.savedDir + '/' + element.filename;
  603 + // });
  604 + // print(str);
  605 +
  606 + // if (str != '') {
  607 + print(savePath);
  608 + progress = null;
  609 + setState(() {});
  610 + OpenFile.open(savePath);
  611 + // _delete();
  612 + // }
  613 + });
  614 + }
  615 + });
  616 + print(response);
  617 + } catch (e) {
  618 + print(e);
  619 + }
  620 +
  621 + // taskId = await FlutterDownloader.enqueue(
  622 + // url:
  623 + // 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
  624 + // headers: {
  625 + // // 'auth': 'test_for_sql_encoding'
  626 + // }, // optional: header send with url (auth token etc)
  627 + // savedDir: _localPath,
  628 + // saveInPublicStorage: true,
  629 + // // fileName:
  630 + // // // showNotification:
  631 + // // // true, // show download progress in status bar (for Android)
  632 + // // openFileFromNotification:
  633 + // // true, // click on notification to open downloaded file (for Android)
  634 + // );
434 }, 635 },
435 ) 636 )
436 ], 637 ],
@@ -80,10 +80,14 @@ Future<PermissionStatus> contactPermissionStatus() async { @@ -80,10 +80,14 @@ Future<PermissionStatus> contactPermissionStatus() async {
80 80
81 Future<bool> requestContactPermission() async { 81 Future<bool> requestContactPermission() async {
82 if (Platform.isAndroid) { 82 if (Platform.isAndroid) {
83 - //全局提示权限使用目的  
84 - BuildContext context = App.navigatorKey.currentState.overlay.context;  
85 - DialogUtil.showAuthorityDestination(  
86 - context, 'h_contant', '通讯录权限使用说明', '直接从通讯录获得客户电话号码,快速录入预订信息。'); 83 + PermissionStatus permissionStatus = await Permission.contacts.status;
  84 +
  85 + if (permissionStatus != PermissionStatus.permanentlyDenied) {
  86 +//全局提示权限使用目的
  87 + BuildContext context = App.navigatorKey.currentState.overlay.context;
  88 + DialogUtil.showAuthorityDestination(
  89 + context, 'h_contant', '通讯录权限使用说明', '直接从通讯录获得客户电话号码,快速录入预订信息。');
  90 + }
87 } 91 }
88 final permissions = await [Permission.contacts].request(); 92 final permissions = await [Permission.contacts].request();
89 if (permissions[Permission.contacts] == PermissionStatus.granted) { 93 if (permissions[Permission.contacts] == PermissionStatus.granted) {
@@ -462,7 +462,7 @@ packages: @@ -462,7 +462,7 @@ packages:
462 name: ffi 462 name: ffi
463 url: "https://pub.flutter-io.cn" 463 url: "https://pub.flutter-io.cn"
464 source: hosted 464 source: hosted
465 - version: "1.1.2" 465 + version: "2.0.2"
466 fijkplayer: 466 fijkplayer:
467 dependency: "direct main" 467 dependency: "direct main"
468 description: 468 description:
@@ -910,6 +910,13 @@ packages: @@ -910,6 +910,13 @@ packages:
910 url: "https://pub.flutter-io.cn" 910 url: "https://pub.flutter-io.cn"
911 source: hosted 911 source: hosted
912 version: "1.0.2" 912 version: "1.0.2"
  913 + open_file:
  914 + dependency: "direct main"
  915 + description:
  916 + name: open_file
  917 + url: "https://pub.flutter-io.cn"
  918 + source: hosted
  919 + version: "3.3.2"
913 package_config: 920 package_config:
914 dependency: transitive 921 dependency: transitive
915 description: 922 description:
@@ -986,7 +993,7 @@ packages: @@ -986,7 +993,7 @@ packages:
986 name: path_provider_windows 993 name: path_provider_windows
987 url: "https://pub.flutter-io.cn" 994 url: "https://pub.flutter-io.cn"
988 source: hosted 995 source: hosted
989 - version: "2.0.7" 996 + version: "2.1.7"
990 pedantic: 997 pedantic:
991 dependency: transitive 998 dependency: transitive
992 description: 999 description:
@@ -1595,7 +1602,7 @@ packages: @@ -1595,7 +1602,7 @@ packages:
1595 name: win32 1602 name: win32
1596 url: "https://pub.flutter-io.cn" 1603 url: "https://pub.flutter-io.cn"
1597 source: hosted 1604 source: hosted
1598 - version: "2.0.5" 1605 + version: "2.7.0"
1599 xdg_directories: 1606 xdg_directories:
1600 dependency: transitive 1607 dependency: transitive
1601 description: 1608 description:
@@ -185,6 +185,7 @@ dependencies: @@ -185,6 +185,7 @@ dependencies:
185 flutter_downloader: ^1.10.5 185 flutter_downloader: ^1.10.5
186 android_path_provider: ^0.3.0 186 android_path_provider: ^0.3.0
187 # open_file: ^3.2.1 187 # open_file: ^3.2.1
  188 + open_file: ^3.3.2
188 189
189 webview_flutter: 190 webview_flutter:
190 path: library/webview_flutter-2.0.13-copy_inappwebview_select_file_20210930 191 path: library/webview_flutter-2.0.13-copy_inappwebview_select_file_20210930