Configuring Scroll Direction and Page Transitions in Our Flutter Viewer

You can programmatically configure the page transition, scroll direction, and scroll mode of a PSPDFKitView in its configuration dictionary.

You need to be aware of the following constraints when using these configuration properties (scrollContinuously, pageTransition, pageScrollDirection, and pageMode) simultaneously.

Scroll Per Spread Page Transition

If you’re using a scroll per spread page transition (also called Jump), there are no constraints:

  • The page scroll direction can be either horizontal or vertical.

  • If the vertical scroll direction is used, the pageMode property can be single, double, or automatic.

// First copy the document from assets to the temporary directory.
await Pspdfkit.present(document.path, {
    pageScrollContinuous: false, // Set the `scrollPerSpread` page transition.
    pageScrollDirection: pageScrollDirectionVertical, // Can also be `pageScrollDirectionHorizontal`.
    pageLayoutMode: 'single' // Can also be `.double` or `.automatic`.
});

Scroll Continuous Page Transition

If you’re using a scroll continuous page transition:

  • The page scroll direction can be either horizontal or vertical.

  • If the vertical scroll direction is used, the pageMode property can be single, double, or automatic. It will be forced to single if the horizontal scroll direction is used.

// First copy the document from assets to the temporary directory.
await Pspdfkit.present(document.path, {
    pageScrollContinuous: true, // Set the `scrollContinuous` page transition.
    pageScrollDirection: pageScrollDirectionVertical, // Can also be `pageScrollDirectionHorizontal`.
    pageLayoutMode: 'single' // Can also be `.double` or `.automatic` for vertical scroll direction.
});

User Interface

Android
iOS

To show the page transition buttons in the user interface, you can use the setting menu items property in the configuration. Here’s how to do this:

// First copy the document from assets to the temporary directory.
await Pspdfkit.present(document.path, {
    // For Android:
    androidSettingsMenuItems: [
        'scrolldirection',
        'pageTransition'
        'pageLayout'
    ],

    // For iOS, first show the settings button item.
    iOSRightBarButtonItems: ['settingsButtonItem'],

    // Then configure the settings menu items.
    iOSSettingsMenuItems: [
        'scrollDirection',
        'pageTransition',
        'pageMode',
        'spreadFitting'
    ]
});