Skip to content
New issue

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

Fail in jumpToPage #65

Closed
PrismaSoftGC opened this issue May 13, 2020 · 1 comment
Closed

Fail in jumpToPage #65

PrismaSoftGC opened this issue May 13, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@PrismaSoftGC
Copy link

Describe
The jumpToPage method just doesn't work

To Reproduce
Steps to reproduce the behavior:

  1. Click on arrow next button in AppBar
    WhatsApp Image 2020-05-13 at 15 49 01
import 'package:flutter/material.dart';
import 'package:native_pdf_view/native_pdf_view.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _actualPageNumber = 1, _allPagesCount = 0;
  PdfController _pdfController;

  @override
  void initState() {
    _pdfController = PdfController(
      document: PdfDocument.openAsset('assets/sample.pdf'),
    );
    super.initState();
  }

  @override
  void dispose() {
    _pdfController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => MaterialApp(
        theme: ThemeData(primaryColor: Colors.white),
        home: Scaffold(
          appBar: AppBar(
            title: Text('PdfView example'),
            actions: <Widget>[
              Container(
                margin: EdgeInsets.only(right: 16),
                alignment: Alignment.center,
                child: Text(
                  '$_actualPageNumber/$_allPagesCount',
                  style: TextStyle(fontSize: 22),
                ),
              ),
              IconButton(
                icon: Icon(Icons.navigate_next),
                onPressed: () {
                  _pdfController.jumpToPage(_pdfController.page + 1);
                },
              )
            ],
          ),
          body: PdfView(
            documentLoader: Center(child: CircularProgressIndicator()),
            pageLoader: Center(child: CircularProgressIndicator()),
            controller: _pdfController,
            onDocumentLoaded: (document) {
              setState(() {
                _allPagesCount = document.pagesCount;
              });
            },
            onPageChanged: (page) {
              setState(() {
                _actualPageNumber = page;
              });
            },
          ),
        ),
      );
}

Smartphone

  • Device: [Samgung J7 prime 2]
  • OS: [Android 9]

Flutter doctor
issue native pdf

@PrismaSoftGC PrismaSoftGC added the bug Something isn't working label May 13, 2020
@SergeShkurko
Copy link
Member

thanks, fixed in 3.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants