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

Fixed setPage return value from int to bool on iOS #118

Merged
merged 1 commit into from Nov 24, 2020

Conversation

daisuke310vvv
Copy link
Contributor

@daisuke310vvv daisuke310vvv commented Nov 23, 2020

Hi, I realized that setPage method returns wrong type on iOS.
As you can see below, Android and iOS returns different value and flutter receives as type bool.

// Android
    void setPage(MethodCall call, Result result) {
        if (call.argument("page") != null) {
            int page = (int) call.argument("page");
            pdfView.jumpTo(page);
        }

        result.success(true); // <- Returns value as type `bool`
    }
// iOS
- (void)setPage:(FlutterMethodCall*)call result:(FlutterResult)result {
    NSDictionary<NSString*, NSNumber*>* arguments = [call arguments];
    NSNumber* page = arguments[@"page"];
    
    [_pdfView goToPage: [_pdfView.document pageAtIndex: page.unsignedLongValue ]];
    result(_currentPage); // <- Returns valus as `int`
}
// Flutter

  Future<bool> setPage(int page) async {
    final bool isSet = await _channel.invokeMethod('setPage', <String, dynamic>{
      'page': page,
    });
    return isSet;
  }

then, we crash on iOS when calling setPage

Exception has occurred.
_CastError (type 'int' is not a subtype of type 'bool' in type cast)

@endigo endigo merged commit 997e991 into endigo:master Nov 24, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants