赞
踩
使用前需要初始化
await FlutterDownloader.initialize(debug: debug);
import 'dart:isolate'; import 'dart:ui'; import 'dart:async'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:permission_handler/permission_handler.dart'; const debug = true; class FlutterDownloaderDemo extends StatefulWidget with WidgetsBindingObserver { @override _FlutterDownloaderDemoState createState() => new _FlutterDownloaderDemoState(); } class _FlutterDownloaderDemoState extends State<FlutterDownloaderDemo> { final _documents = [ { 'name': 'Learning Android Studio', 'link': 'http://barbra-coco.dyndns.org/student/learning_android_studio.pdf' }, { 'name': 'Android Programming Cookbook', 'link': 'http://enos.itcollege.ee/~jpoial/allalaadimised/reading/Android-Programming-Cookbook.pdf' }, { 'name': 'iOS Programming Guide', 'link': 'http://darwinlogic.com/uploads/education/iOS_Programming_Guide.pdf' }, { 'name': 'Objective-C Programming (Pre-Course Workbook', 'link': 'https://www.bignerdranch.com/documents/objective-c-prereading-assignment.pdf' }, ]; final _images = [ { 'name': 'Arches National Park', 'link': 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb.zol-img.com.cn%2Fsjbizhi%2Fimages%2F5%2F320x510%2F137760363184.jpg&refer=http%3A%2F%2Fb.zol-img.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624849370&t=fb018c3ff3c939cf5dd5fb52210bec7d' }, { 'name': 'Canyonlands National Park', 'link': 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01251f57c36e000000012e7e27412c.jpg&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624849370&t=609a5f51ecaa96b8e39b8747ea2fa2b2' }, { 'name': 'Death Valley National Park', 'link': 'https://upload.wikimedia.org/wikipedia/commons/b/b2/Sand_Dunes_in_Death_Valley_National_Park.jpg' }, { 'name': 'Gates of the Arctic National Park and Preserve', 'link': 'https://upload.wikimedia.org/wikipedia/commons/e/e4/GatesofArctic.jpg' } ]; final _videos = [ { 'name': 'Big Buck Bunny', 'link': 'http://commondatastorage.flutter-io.cn/gtv-videos-bucket/sample/BigBuckBunny.mp4' }, { 'name': 'Elephant Dream', 'link': 'http://commondatastorage.flutter-io.cn/gtv-videos-bucket/sample/ElephantsDream.mp4' } ]; //任务列表 List<_TaskInfo> _tasks; //项目列表 List<_ItemHolder> _items; //是否在加载 bool _isLoading; //用户是否同意权限 bool _permissionReady; //存储路径 String _localPath; //接收端口 ReceivePort _port = ReceivePort(); @override void
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。