[英]Show download percentage in the Flutter Circular Progress Indicator
I am using Flutter advance_pdf_viewer package to show PDF files that are loaded from the URL. At the first time open, The PDF files are downloaded in the application cache and the next time onwards loaded from the cache.我正在使用 Flutter advance_pdf_viewer package 来显示从 URL 加载的 PDF 个文件。第一次打开时,PDF 个文件在应用程序缓存中下载,下次从缓存中加载。 Now I am using CircularProgressIndicator() to show the download progress.
现在我使用 CircularProgressIndicator() 来显示下载进度。 I want to add the progress percentage here to give the user better visibility of the progress.
我想在这里添加进度百分比,让用户更好地了解进度。 How can I do that?
我怎样才能做到这一点?
Here is my code:这是我的代码:
import 'package:flutter/material.dart';
import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
@override
_MyBanBook createState() => _MyBanBook();
}
class _MyBanBook extends State<BanBook> {
bool _isLoading = true;
PDFDocument document;
@override
void initState() {
super.initState();
loadDocument();
}
loadDocument() async {
document = await PDFDocument.fromURL('http://www.africau.edu/images/default/sample.pdf');
setState(() => _isLoading = false);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
toolbarHeight: 20,
),
body: Center(
child: _isLoading
? Center(child: CircularProgressIndicator())
: PDFViewer(
document: document,
zoomSteps: 1,
),
),
bottomNavigationBar: BottomAppBar(
child: Container(
height: 85.0,
),
),
),
);
}
}
You can do it by specifying the value property in the CircularProgressIndicator
like this:您可以通过在
CircularProgressIndicator
中指定 value 属性来实现,如下所示:
CircularProgressIndicator(
value: _progress,
//width of the width of the border
strokeWidth: 20,
// color of value
valueColor: Colors.amber
);
u can use flutter_cached_pdfview你可以使用flutter_cached_pdfview
PDF().cachedFromUrl( 'http://africau.edu/images/default/sample.pdf', placeholder: (progress) => Center(child: CircularProgressIndicator()) )
take a look https://pub.dev/packages/flutter_cached_pdfview看看https://pub.dev/packages/flutter_cached_pdfview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.