|
@@ -8,21 +8,27 @@ import 'package:dio/dio.dart'; |
|
@@ -8,21 +8,27 @@ import 'package:dio/dio.dart'; |
|
8
|
import 'package:flutter/material.dart';
|
8
|
import 'package:flutter/material.dart';
|
|
9
|
import 'package:flutter_picker/Picker.dart';
|
9
|
import 'package:flutter_picker/Picker.dart';
|
|
10
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
10
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
11
|
+import 'package:one_key/provider/user_model.dart';
|
|
11
|
import 'package:one_key/res/colors.dart';
|
12
|
import 'package:one_key/res/colors.dart';
|
|
12
|
import 'package:one_key/widgets/round_button.dart';
|
13
|
import 'package:one_key/widgets/round_button.dart';
|
|
13
|
import 'package:one_key/widgets/system_app_bar.dart';
|
14
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
14
|
import 'package:one_key/widgets/v_empty_view.dart';
|
15
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
15
|
import 'package:path_provider/path_provider.dart';
|
16
|
import 'package:path_provider/path_provider.dart';
|
|
16
|
import 'package:permission_handler/permission_handler.dart';
|
17
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
18
|
+import 'package:provider/provider.dart';
|
|
17
|
|
19
|
|
|
|
|
20
|
+import '../../../../app.dart';
|
|
18
|
import '../../../../net/dio_util.dart';
|
21
|
import '../../../../net/dio_util.dart';
|
|
19
|
import '../../../../utils/dialog_util.dart';
|
22
|
import '../../../../utils/dialog_util.dart';
|
|
20
|
import '../../../../utils/screen_util.dart';
|
23
|
import '../../../../utils/screen_util.dart';
|
|
21
|
import '../../../../utils/utils.dart';
|
24
|
import '../../../../utils/utils.dart';
|
|
22
|
import '../../../../widgets/h_empty_view.dart';
|
25
|
import '../../../../widgets/h_empty_view.dart';
|
|
23
|
-import 'package:flutter_downloader/flutter_downloader.dart';
|
|
|
|
24
|
-import 'package:android_path_provider/android_path_provider.dart';
|
26
|
+// import 'package:flutter_downloader/flutter_downloader.dart';
|
|
|
|
27
|
+// import 'package:android_path_provider/android_path_provider.dart';
|
|
25
|
import 'package:open_file/open_file.dart';
|
28
|
import 'package:open_file/open_file.dart';
|
|
|
|
29
|
+import 'package:excel/excel.dart' as excelUtil;
|
|
|
|
30
|
+
|
|
|
|
31
|
+import '../../../../widgets/loading.dart';
|
|
26
|
|
32
|
|
|
27
|
/**
|
33
|
/**
|
|
28
|
* 导出预订数据
|
34
|
* 导出预订数据
|
|
@@ -43,11 +49,11 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -43,11 +49,11 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
43
|
|
49
|
|
|
44
|
List<String> data = ['到店时间', '下单时间'];
|
50
|
List<String> data = ['到店时间', '下单时间'];
|
|
45
|
int timeIndex;
|
51
|
int timeIndex;
|
|
46
|
- ReceivePort _port = ReceivePort();
|
52
|
+ // ReceivePort _port = ReceivePort();
|
|
47
|
String _localPath;
|
53
|
String _localPath;
|
|
48
|
|
54
|
|
|
49
|
String taskId;
|
55
|
String taskId;
|
|
50
|
- DownloadTaskStatus status;
|
56
|
+ // DownloadTaskStatus status;
|
|
51
|
int progress;
|
57
|
int progress;
|
|
52
|
|
58
|
|
|
53
|
@override
|
59
|
@override
|
|
@@ -181,21 +187,21 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -181,21 +187,21 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
181
|
super.dispose();
|
187
|
super.dispose();
|
|
182
|
}
|
188
|
}
|
|
183
|
|
189
|
|
|
184
|
- @pragma('vm:entry-point')
|
|
|
|
185
|
- static void downloadCallback(
|
|
|
|
186
|
- String id,
|
|
|
|
187
|
- int status,
|
|
|
|
188
|
- int progress,
|
|
|
|
189
|
- ) {
|
|
|
|
190
|
- final SendPort send =
|
|
|
|
191
|
- IsolateNameServer.lookupPortByName('downloader_send_port');
|
|
|
|
192
|
- send.send([id, status, progress]);
|
|
|
|
193
|
- }
|
190
|
+ // @pragma('vm:entry-point')
|
|
|
|
191
|
+ // static void downloadCallback(
|
|
|
|
192
|
+ // String id,
|
|
|
|
193
|
+ // int status,
|
|
|
|
194
|
+ // int progress,
|
|
|
|
195
|
+ // ) {
|
|
|
|
196
|
+ // final SendPort send =
|
|
|
|
197
|
+ // IsolateNameServer.lookupPortByName('downloader_send_port');
|
|
|
|
198
|
+ // send.send([id, status, progress]);
|
|
|
|
199
|
+ // }
|
|
194
|
|
200
|
|
|
195
|
- // 根据taskId打开下载文件
|
|
|
|
196
|
- Future<bool> _openDownloadedFile(taskId) {
|
|
|
|
197
|
- return FlutterDownloader.open(taskId: taskId);
|
|
|
|
198
|
- }
|
201
|
+ // // 根据taskId打开下载文件
|
|
|
|
202
|
+ // Future<bool> _openDownloadedFile(taskId) {
|
|
|
|
203
|
+ // return FlutterDownloader.open(taskId: taskId);
|
|
|
|
204
|
+ // }
|
|
199
|
|
205
|
|
|
200
|
// void _bindBackgroundIsolate() {
|
206
|
// void _bindBackgroundIsolate() {
|
|
201
|
// final isSuccess = IsolateNameServer.registerPortWithName(
|
207
|
// final isSuccess = IsolateNameServer.registerPortWithName(
|
|
@@ -270,17 +276,17 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -270,17 +276,17 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
270
|
// }
|
276
|
// }
|
|
271
|
// });
|
277
|
// });
|
|
272
|
// }
|
278
|
// }
|
|
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
|
- });
|
|
|
|
282
|
- }
|
|
|
|
283
|
- }
|
279
|
+ // Future<void> _delete() async {
|
|
|
|
280
|
+ // final task = await FlutterDownloader.loadTasks();
|
|
|
|
281
|
+ // if (task != null) {
|
|
|
|
282
|
+ // task.forEach((element) {
|
|
|
|
283
|
+ // FlutterDownloader.remove(
|
|
|
|
284
|
+ // taskId: element.taskId,
|
|
|
|
285
|
+ // shouldDeleteContent: true,
|
|
|
|
286
|
+ // );
|
|
|
|
287
|
+ // });
|
|
|
|
288
|
+ // }
|
|
|
|
289
|
+ // }
|
|
284
|
|
290
|
|
|
285
|
Future<void> _prepareSaveDir() async {
|
291
|
Future<void> _prepareSaveDir() async {
|
|
286
|
_localPath = (await _getSavedDir());
|
292
|
_localPath = (await _getSavedDir());
|
|
@@ -299,9 +305,10 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -299,9 +305,10 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
299
|
// } catch (err, st) {
|
305
|
// } catch (err, st) {
|
|
300
|
// print('failed to get downloads path: $err, $st');
|
306
|
// print('failed to get downloads path: $err, $st');
|
|
301
|
|
307
|
|
|
|
|
308
|
+ // if()/
|
|
|
|
309
|
+
|
|
302
|
final directory = await getExternalStorageDirectory();
|
310
|
final directory = await getExternalStorageDirectory();
|
|
303
|
externalStorageDirPath = directory?.path;
|
311
|
externalStorageDirPath = directory?.path;
|
|
304
|
- // }
|
|
|
|
305
|
} else if (Platform.isIOS) {
|
312
|
} else if (Platform.isIOS) {
|
|
306
|
externalStorageDirPath =
|
313
|
externalStorageDirPath =
|
|
307
|
(await getApplicationDocumentsDirectory()).absolute.path;
|
314
|
(await getApplicationDocumentsDirectory()).absolute.path;
|
|
@@ -325,6 +332,23 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -325,6 +332,23 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
325
|
return true;
|
332
|
return true;
|
|
326
|
}
|
333
|
}
|
|
327
|
|
334
|
|
|
|
|
335
|
+ if (Platform.isAndroid) {
|
|
|
|
336
|
+ // try {
|
|
|
|
337
|
+ // externalStorageDirPath = await AndroidPathProvider.downloadsPath;
|
|
|
|
338
|
+ // } catch (err, st) {
|
|
|
|
339
|
+ // print('failed to get downloads path: $err, $st');
|
|
|
|
340
|
+
|
|
|
|
341
|
+ // if()/
|
|
|
|
342
|
+ PermissionStatus permissionStatus = await Permission.storage.status;
|
|
|
|
343
|
+
|
|
|
|
344
|
+ if (permissionStatus != PermissionStatus.permanentlyDenied) {
|
|
|
|
345
|
+//全局提示权限使用目的
|
|
|
|
346
|
+ BuildContext context = App.navigatorKey.currentState.overlay.context;
|
|
|
|
347
|
+ DialogUtil.showAuthorityDestination(
|
|
|
|
348
|
+ context, 'h_storage', '存储权限使用说明', '用于存储下载的预订表。');
|
|
|
|
349
|
+ }
|
|
|
|
350
|
+ }
|
|
|
|
351
|
+
|
|
328
|
final result = await Permission.storage.request();
|
352
|
final result = await Permission.storage.request();
|
|
329
|
return result == PermissionStatus.granted;
|
353
|
return result == PermissionStatus.granted;
|
|
330
|
}
|
354
|
}
|
|
@@ -332,9 +356,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -332,9 +356,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
332
|
throw StateError('unknown platform');
|
356
|
throw StateError('unknown platform');
|
|
333
|
}
|
357
|
}
|
|
334
|
|
358
|
|
|
335
|
- void _unbindBackgroundIsolate() {
|
|
|
|
336
|
- IsolateNameServer.removePortNameMapping('downloader_send_port');
|
|
|
|
337
|
- }
|
359
|
+ // void _unbindBackgroundIsolate() {
|
|
|
|
360
|
+ // IsolateNameServer.removePortNameMapping('downloader_send_port');
|
|
|
|
361
|
+ // }
|
|
338
|
|
362
|
|
|
339
|
///时间选择
|
363
|
///时间选择
|
|
340
|
Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
364
|
Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
|
@@ -418,6 +442,86 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -418,6 +442,86 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
418
|
return data;
|
442
|
return data;
|
|
419
|
}
|
443
|
}
|
|
420
|
|
444
|
|
|
|
|
445
|
+ void _download() async {
|
|
|
|
446
|
+ Loading.showLoading(
|
|
|
|
447
|
+ context,
|
|
|
|
448
|
+ );
|
|
|
|
449
|
+ Stopwatch stopwatch = new Stopwatch()..start();
|
|
|
|
450
|
+
|
|
|
|
451
|
+ excelUtil.Excel excel = excelUtil.Excel.createExcel();
|
|
|
|
452
|
+ excelUtil.Sheet sh = excel['Sheet1'];
|
|
|
|
453
|
+ //表头
|
|
|
|
454
|
+ for (int i = 0; i < 8; i++) {
|
|
|
|
455
|
+ sh
|
|
|
|
456
|
+ .cell(
|
|
|
|
457
|
+ excelUtil.CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i))
|
|
|
|
458
|
+ .value = 'Column $i';
|
|
|
|
459
|
+ //sh.cell(CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i)).cellStyle =CellStyle(bold: true);
|
|
|
|
460
|
+ }
|
|
|
|
461
|
+ for (int row = 1; row < 9; row++) {
|
|
|
|
462
|
+ for (int column = 0; column < 8; column++) {
|
|
|
|
463
|
+ sh
|
|
|
|
464
|
+ .cell(excelUtil.CellIndex.indexByColumnRow(
|
|
|
|
465
|
+ rowIndex: row, columnIndex: column))
|
|
|
|
466
|
+ .value = '$row$column value';
|
|
|
|
467
|
+ }
|
|
|
|
468
|
+ }
|
|
|
|
469
|
+ print('Generating executed in ${stopwatch.elapsed}');
|
|
|
|
470
|
+ stopwatch.reset();
|
|
|
|
471
|
+ var fileBytes = excel.encode();
|
|
|
|
472
|
+
|
|
|
|
473
|
+ print('Encoding executed in ${stopwatch.elapsed}');
|
|
|
|
474
|
+ stopwatch.reset();
|
|
|
|
475
|
+ String sellername =
|
|
|
|
476
|
+ Provider.of<UserModel>(context, listen: false).user.sellername;
|
|
|
|
477
|
+ String starttime = fromDate.replaceAll('-', '');
|
|
|
|
478
|
+ String endtime = endDate.replaceAll('-', '');
|
|
|
|
479
|
+ if (fileBytes != null) {
|
|
|
|
480
|
+ File file =
|
|
|
|
481
|
+ File(_localPath + "/${sellername}${starttime}至${endtime}预订.xlsx")
|
|
|
|
482
|
+ ..createSync(recursive: true)
|
|
|
|
483
|
+ ..writeAsBytesSync(fileBytes);
|
|
|
|
484
|
+ file.copy('/storage/emulated/0/Download/dongle.xlsx');
|
|
|
|
485
|
+ Loading.hideLoading(context);
|
|
|
|
486
|
+ DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
487
|
+ title: '提示',
|
|
|
|
488
|
+ content: '文件下载完成,是否打开?',
|
|
|
|
489
|
+ lTitle: '取消',
|
|
|
|
490
|
+ rTitle: '打开', lCallback: () {
|
|
|
|
491
|
+ progress = null;
|
|
|
|
492
|
+ setState(() {});
|
|
|
|
493
|
+ }, rCallback: () async {
|
|
|
|
494
|
+ // Navigator.pop(context);
|
|
|
|
495
|
+
|
|
|
|
496
|
+ // print(_localPath);
|
|
|
|
497
|
+
|
|
|
|
498
|
+ // final tasks = await FlutterDownloader.loadTasks();
|
|
|
|
499
|
+ // String str = '';
|
|
|
|
500
|
+ // tasks.forEach((element) {
|
|
|
|
501
|
+ // str = element.savedDir + '/' + element.filename;
|
|
|
|
502
|
+ // });
|
|
|
|
503
|
+ // print(str);
|
|
|
|
504
|
+
|
|
|
|
505
|
+ // if (str != '') {
|
|
|
|
506
|
+ // print(savePath);
|
|
|
|
507
|
+ // progress = null;
|
|
|
|
508
|
+ // setState(() {});
|
|
|
|
509
|
+ OpenFile.open(
|
|
|
|
510
|
+ _localPath + "/${sellername}${starttime}至${endtime}预订.xlsx");
|
|
|
|
511
|
+ // _delete();
|
|
|
|
512
|
+ // }
|
|
|
|
513
|
+ });
|
|
|
|
514
|
+ } else {
|
|
|
|
515
|
+ Loading.hideLoading(context);
|
|
|
|
516
|
+ }
|
|
|
|
517
|
+
|
|
|
|
518
|
+ print('Downloaded executed in ${stopwatch.elapsed}');
|
|
|
|
519
|
+ }
|
|
|
|
520
|
+
|
|
|
|
521
|
+ Future<bool> openSetting() {
|
|
|
|
522
|
+ return openAppSettings();
|
|
|
|
523
|
+ }
|
|
|
|
524
|
+
|
|
421
|
@override
|
525
|
@override
|
|
422
|
Widget build(BuildContext context) {
|
526
|
Widget build(BuildContext context) {
|
|
423
|
return Scaffold(
|
527
|
return Scaffold(
|
|
@@ -554,87 +658,98 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -554,87 +658,98 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
554
|
fontSize: 32,
|
658
|
fontSize: 32,
|
|
555
|
isBold: true,
|
659
|
isBold: true,
|
|
556
|
onPressed: () async {
|
660
|
onPressed: () async {
|
|
557
|
- if (progress != null) {
|
661
|
+ // if (progress != null) {
|
|
|
|
662
|
+ // return;
|
|
|
|
663
|
+ // }
|
|
|
|
664
|
+
|
|
|
|
665
|
+ if (timeType == '点击选择') {
|
|
|
|
666
|
+ Utils.showToast('请选择时间类型');
|
|
|
|
667
|
+ return;
|
|
|
|
668
|
+ }
|
|
|
|
669
|
+ if (fromDate == '点击选择') {
|
|
|
|
670
|
+ Utils.showToast('请选择开始日期');
|
|
|
|
671
|
+ return;
|
|
|
|
672
|
+ }
|
|
|
|
673
|
+ if (endDate == '点击选择') {
|
|
|
|
674
|
+ Utils.showToast('请选择结束日期');
|
|
558
|
return;
|
675
|
return;
|
|
559
|
}
|
676
|
}
|
|
560
|
|
677
|
|
|
561
|
bool _permissionReady = await _checkPermission();
|
678
|
bool _permissionReady = await _checkPermission();
|
|
562
|
if (_permissionReady) {
|
679
|
if (_permissionReady) {
|
|
563
|
await _prepareSaveDir();
|
680
|
await _prepareSaveDir();
|
|
564
|
- }
|
|
|
|
565
|
- // _delete();
|
|
|
|
566
|
- String savePath = _localPath + "/fff.pdf";
|
|
|
|
567
|
- Directory directory = new Directory(savePath);
|
|
|
|
568
|
- if (directory.existsSync()) {
|
|
|
|
569
|
- //删除历史
|
|
|
|
570
|
- final List<FileSystemEntity> files = directory.listSync();
|
|
|
|
571
|
- for (FileSystemEntity file in files) {
|
|
|
|
572
|
- file.deleteSync();
|
|
|
|
573
|
- }
|
|
|
|
574
|
- }
|
|
|
|
575
|
-
|
|
|
|
576
|
- try {
|
|
|
|
577
|
- Response response = await DioUtil().download(
|
|
|
|
578
|
- 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
|
|
|
|
579
|
- savePath, onProgress: (received, total) {
|
|
|
|
580
|
- if (progress != 100) {
|
|
|
|
581
|
- progress = ((received / total) * 100).round();
|
|
|
|
582
|
-
|
|
|
|
583
|
- setState(() {});
|
|
|
|
584
|
- }
|
|
|
|
585
|
- if (received == total) {
|
|
|
|
586
|
- //下载完成
|
|
|
|
587
|
- print('xaizaiwancheng');
|
|
|
|
588
|
-
|
|
|
|
589
|
- DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
590
|
- title: '提示',
|
|
|
|
591
|
- content: '文件下载完成,是否打开?',
|
|
|
|
592
|
- lTitle: '取消',
|
|
|
|
593
|
- rTitle: '打开', lCallback: () {
|
|
|
|
594
|
- progress = null;
|
|
|
|
595
|
- setState(() {});
|
|
|
|
596
|
- }, rCallback: () async {
|
|
|
|
597
|
- // Navigator.pop(context);
|
|
|
|
598
|
-
|
|
|
|
599
|
- // print(_localPath);
|
|
|
|
600
|
-
|
|
|
|
601
|
- // final tasks = await FlutterDownloader.loadTasks();
|
|
|
|
602
|
- // String str = '';
|
|
|
|
603
|
- // tasks.forEach((element) {
|
|
|
|
604
|
- // str = element.savedDir + '/' + element.filename;
|
|
|
|
605
|
- // });
|
|
|
|
606
|
- // print(str);
|
|
|
|
607
|
-
|
|
|
|
608
|
- // if (str != '') {
|
|
|
|
609
|
- print(savePath);
|
|
|
|
610
|
- progress = null;
|
|
|
|
611
|
- setState(() {});
|
|
|
|
612
|
- OpenFile.open(savePath);
|
|
|
|
613
|
- // _delete();
|
|
|
|
614
|
- // }
|
|
|
|
615
|
- });
|
|
|
|
616
|
- }
|
681
|
+ _download();
|
|
|
|
682
|
+ } else {
|
|
|
|
683
|
+ String title = Platform.isAndroid ? '存储' : '相册';
|
|
|
|
684
|
+
|
|
|
|
685
|
+ //用户选择不在弹出权限提示框
|
|
|
|
686
|
+ print('never');
|
|
|
|
687
|
+ // Navigator.pop(context);
|
|
|
|
688
|
+ DialogUtil.openAlertDialog(context, '未获得${title}权限',
|
|
|
|
689
|
+ "请在手机的权限管理里,将${title}权限开启", '去设置', 340.0, onTap: () {
|
|
|
|
690
|
+ openSetting();
|
|
|
|
691
|
+ Navigator.pop(context, '');
|
|
617
|
});
|
692
|
});
|
|
618
|
- print(response);
|
|
|
|
619
|
- } catch (e) {
|
|
|
|
620
|
- print(e);
|
|
|
|
621
|
- Utils.showToast('下载异常,请稍后重试');
|
|
|
|
622
|
}
|
693
|
}
|
|
623
|
|
694
|
|
|
624
|
- // taskId = await FlutterDownloader.enqueue(
|
|
|
|
625
|
- // url:
|
695
|
+ // _delete();
|
|
|
|
696
|
+ // String savePath = _localPath + "/fff.pdf";
|
|
|
|
697
|
+ // Directory directory = new Directory(savePath);
|
|
|
|
698
|
+ // if (directory.existsSync()) {
|
|
|
|
699
|
+ // //删除历史
|
|
|
|
700
|
+ // final List<FileSystemEntity> files = directory.listSync();
|
|
|
|
701
|
+ // for (FileSystemEntity file in files) {
|
|
|
|
702
|
+ // file.deleteSync();
|
|
|
|
703
|
+ // }
|
|
|
|
704
|
+ // }
|
|
|
|
705
|
+
|
|
|
|
706
|
+ // try {
|
|
|
|
707
|
+ // Response response = await DioUtil().download(
|
|
626
|
// 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
|
708
|
// 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
|
|
627
|
- // headers: {
|
|
|
|
628
|
- // // 'auth': 'test_for_sql_encoding'
|
|
|
|
629
|
- // }, // optional: header send with url (auth token etc)
|
|
|
|
630
|
- // savedDir: _localPath,
|
|
|
|
631
|
- // saveInPublicStorage: true,
|
|
|
|
632
|
- // // fileName:
|
|
|
|
633
|
- // // // showNotification:
|
|
|
|
634
|
- // // // true, // show download progress in status bar (for Android)
|
|
|
|
635
|
- // // openFileFromNotification:
|
|
|
|
636
|
- // // true, // click on notification to open downloaded file (for Android)
|
|
|
|
637
|
- // );
|
709
|
+ // savePath, onProgress: (received, total) {
|
|
|
|
710
|
+ // if (progress != 100) {
|
|
|
|
711
|
+ // progress = ((received / total) * 100).round();
|
|
|
|
712
|
+
|
|
|
|
713
|
+ // setState(() {});
|
|
|
|
714
|
+ // }
|
|
|
|
715
|
+ // if (received == total) {
|
|
|
|
716
|
+ // //下载完成
|
|
|
|
717
|
+ // print('xaizaiwancheng');
|
|
|
|
718
|
+
|
|
|
|
719
|
+ // DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
720
|
+ // title: '提示',
|
|
|
|
721
|
+ // content: '文件下载完成,是否打开?',
|
|
|
|
722
|
+ // lTitle: '取消',
|
|
|
|
723
|
+ // rTitle: '打开', lCallback: () {
|
|
|
|
724
|
+ // progress = null;
|
|
|
|
725
|
+ // setState(() {});
|
|
|
|
726
|
+ // }, rCallback: () async {
|
|
|
|
727
|
+ // // Navigator.pop(context);
|
|
|
|
728
|
+
|
|
|
|
729
|
+ // // print(_localPath);
|
|
|
|
730
|
+
|
|
|
|
731
|
+ // // final tasks = await FlutterDownloader.loadTasks();
|
|
|
|
732
|
+ // // String str = '';
|
|
|
|
733
|
+ // // tasks.forEach((element) {
|
|
|
|
734
|
+ // // str = element.savedDir + '/' + element.filename;
|
|
|
|
735
|
+ // // });
|
|
|
|
736
|
+ // // print(str);
|
|
|
|
737
|
+
|
|
|
|
738
|
+ // // if (str != '') {
|
|
|
|
739
|
+ // print(savePath);
|
|
|
|
740
|
+ // progress = null;
|
|
|
|
741
|
+ // setState(() {});
|
|
|
|
742
|
+ // OpenFile.open(savePath);
|
|
|
|
743
|
+ // // _delete();
|
|
|
|
744
|
+ // // }
|
|
|
|
745
|
+ // });
|
|
|
|
746
|
+ // }
|
|
|
|
747
|
+ // });
|
|
|
|
748
|
+ // print(response);
|
|
|
|
749
|
+ // } catch (e) {
|
|
|
|
750
|
+ // print(e);
|
|
|
|
751
|
+ // Utils.showToast('下载异常,请稍后重试');
|
|
|
|
752
|
+ // }
|
|
638
|
},
|
753
|
},
|
|
639
|
)
|
754
|
)
|
|
640
|
],
|
755
|
],
|