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

setPage fails with TypeError. #12

Open
janniklind opened this issue Aug 27, 2020 · 3 comments
Open

setPage fails with TypeError. #12

janniklind opened this issue Aug 27, 2020 · 3 comments

Comments

@janniklind
Copy link

setPage returns int:

- (void)setPage:(FlutterMethodCall*)call result:(FlutterResult)result {

But the caller expects a boolean to be returned:

final bool isSet = await _channel.invokeMethod('setPage', <String, dynamic>{

@arnaudelub
Copy link
Owner

Hi,
setPage is working correctly, it's a bool because we need to know that the page has been set on the native side (APV) or not, so true => Page has been set correctly, false => an error occurs

@janniklind
Copy link
Author

janniklind commented Sep 3, 2020

@arnaudelub have you tried to run the code? :)

It does set the page yes, but it throws and error right after when it tries to cast the _currentPage integer returned in the platform channel to bool in the dart code.

You can fix it using a try catch like below, but not the finest :)

      try {
        await pdfViewController.setPage(0);
      } on TypeError {
        // Ignore - It sets the page correctly, but fails when trying to cast the current page integer to bool later on.
      }

@janniklind janniklind changed the title setPage doesn't work. setPage fails with TypeError. Sep 3, 2020
@arnaudelub
Copy link
Owner

Ok, thank you, I'll check that

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

No branches or pull requests

2 participants