Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Unable to JumpTo particular page after load from url #118

Open
mumairofficial opened this issue Nov 23, 2022 · 0 comments
Open

Unable to JumpTo particular page after load from url #118

mumairofficial opened this issue Nov 23, 2022 · 0 comments

Comments

@mumairofficial
Copy link

I am trying to jump to a specific page once the PDF file is loaded from either URL or File. Here is what I have tried, not sure what's wrong.

class _PublicationReaderScreenState extends State<PublicationReaderScreen> {
  late PDFDocument document;
  bool _loading = true;
  final PageController _pageController = PageController();

  @override
  void initState() {
    super.initState();
    loadDocument();
    // _pageController.jumpTo(5.0);
  }

  loadDocument() async {
    document = await PDFDocument.fromURL(widget.publication.downloadUrl);
    setState(() {
      _loading = false;
    });
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 1,
      ),
      body: _loading
          ? const Center(child: CircularProgressIndicator())
          : PDFViewer(
              document: document,
              zoomSteps: 1,
              lazyLoad: true,
              pickerButtonColor: Theme.of(context).colorScheme.primary,
              controller: _pageController,
              showIndicator: true,
              onPageChanged: (int p) {
                print(p+1);
              },
            ),
    );
  }
}

Tried PageController but no success!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant