PDFTron as a widget expands navigation bar on Android

When using the PDFTron Flutter library as a widget it expands the Navigation bar to compensate for the status bar or changes the System UI Overlays, I’m not 100% sure what or why it’s doing. This does not happen on iOS, only affected in Android.

Steps to Reproduce the Problem
I created a simple example app based on the same pdftron_flutter example, which has a view where you can push a button to navigate to PDFTron widget.

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pdftron_flutter/pdftron_flutter.dart';

void main() {
  runApp(MaterialApp(
    title: 'Example',
    home: FirstRoute(),
  ));
}

class FirstRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('First Route'),
      ),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              child: Text('Open PDFTronWidget'),
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => Viewer(key: UniqueKey())),
                );
              },
            ),
          ]
        )
      ),
    );
  }
}

class Viewer extends StatefulWidget {

  Viewer({Key key}) : super(key: key);

  @override
  _ViewerState createState() => _ViewerState();
}

class _ViewerState extends State<Viewer> {
  String _version = 'Unknown';
  String _document = "http://www.africau.edu/images/default/sample.pdf";
  bool _showViewer = true;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    String version;
    try {
      PdftronFlutter.initialize("your_pdftron_license_key");
      version = await PdftronFlutter.version;
    } on PlatformException {
      version = 'Failed to get platform version.';
    }
    if (!mounted) return;
    setState(() {
      _version = version;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('PdfTron'),
      ),
      body: Container(
        width: double.infinity,
        height: double.infinity,
        child: _showViewer ? DocumentView(
          onCreated: _onDocumentViewCreated,
        ): Container(),
      ),
    );
  }

  void _onDocumentViewCreated(DocumentViewController controller) async {
    var leadingNavCancel = startLeadingNavButtonPressedListener(() {
      Navigator.pop(context);
    });
    controller.openDocument(_document);
  }

}

In the first view, everything is normal.

When opening PDFTron widget the screen jumps a few times and the navigation bar doubles in size.

When navigating back with the back button, nothing changes. When opening the app again, something is recalculated and everything returns to normal. This occurs even when not using a navigation bar in the PDFTron widget view itself.

Expected behavior
Using the PDFTron library as a widget should not change the status bar and padding, or whatever it does. This works great on iOS devices, and is probably related to the native Android PDFTron library.

Hi @adil.mobologics

Thanks for the screenshot and dart file. I have tried running the code and can’t seem to be able to reproduce the issue.

Even after multiple attempts at going back and forth I’m not running into your issues.

Could you please provide a video and runnable sample project?

Thanks,
Andrew.

Thank you @ama for responding,

Hello, I have pushed a sample dummy project to github. Please have a look at it. You will see a gap between appbar and statusbar . And I have uploaded a video to google drive. You can see it.
video google drive link: WhatsApp Video 2022-10-06 at 11.11.11 PM.mp4 - Google Drive

github repo: GitHub - adiShinwari/pdf_test

Hi @adil.mobologics

I was able to run your sample project and reproduce the issue. We will look into fixing this issue. Could you let us know if this item is blocking you, or any timelines you may have?

Thanks,
Andrew.

@ama
I am about to publish my app. The app is in last phases. I have like 2-3 days

@ama
I didn’t get a response. I am publishing my app and still have the same issue

Hi @adil.mobologics

Unfortunately we will not be able to make that deadline. We will update you as soon as the fix is available.

Thanks,
Andrew.

hey @ama
I am facing the issue for the past 12 months. It should be fixed by now.

Hello adil.mobologics,

This fix is still in the backlog, apologies for the delay. We will update you when the fix has been completed.

Best regards,
Tyler Gordon
Web Development Support Engineer
PDFTron