We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i this code that i used in our application i get zero for getting page count
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_cached_pdfview/flutter_cached_pdfview.dart'; import 'package:velocity_x/velocity_x.dart'; class ShowPdfFromUrl extends StatefulWidget { final String pdfUrl; final String productName; ShowPdfFromUrl({@required this.pdfUrl, @required this.productName}); @override _ShowPdfFromUrlState createState() => _ShowPdfFromUrlState(); } class _ShowPdfFromUrlState extends State<ShowPdfFromUrl> { final Completer<PDFViewController> _pdfViewController = Completer<PDFViewController>(); final ValueNotifier<int> _pageCount = ValueNotifier<int>(0); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( '${widget.productName}', overflow: TextOverflow.ellipsis, maxLines: 1, ), ), body: Stack( children: [ PDF( onViewCreated: (PDFViewController pdfViewController) async { _pdfViewController.complete(pdfViewController); _pageCount.value = await pdfViewController.getPageCount(); }, ).cachedFromUrl( '${widget.pdfUrl}', placeholder: (progress) => Center(child: Text('Yükleniyor $progress % ...')), errorWidget: (error) { return Center( child: Container( width: context.screenWidth, height: context.screenHeight, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text('PDF hatası indiriliyor'), Padding( padding: const EdgeInsets.only(top: 16.0), child: OutlineButton( onPressed: () { setState(() {}); }, child: Text('lütfen tekrar deneyin'), ), ), ], ), )); }, ), Positioned( top: 8.0, left: 8.0, child: ValueListenableBuilder( valueListenable: _pageCount, builder: (_,value,__){ return Container( padding: EdgeInsets.all(8.0), color: Colors.black, child: Text('($value)',style: TextStyle( color: Colors.white, ),), ); }, ), ), ], ), ); } }
The text was updated successfully, but these errors were encountered:
hi @MahdiPishguy try this
PDF( onPageChanged: (page, total) { _pageCount.value = total; }, onViewCreated: (PDFViewController pdfViewController) async { _pdfViewController.complete(pdfViewController); _pageCount.value = await pdfViewController.getPageCount(); }, )
Sorry, something went wrong.
explain the prob pdfViewController was created but pdf file still downloading or get from cache
if this solution worked with you please let me know and close issue
Yes, thanks a lot, 🥇
binSaed
No branches or pull requests
i this code that i used in our application i get zero for getting page count
The text was updated successfully, but these errors were encountered: