Skip to main content
The Stac PageView allows you to build a Flutter PageView widget using JSON. To know more about the PageView widget in Flutter, refer to the official documentation.

Properties

PropertyTypeDescription
scrollDirectionStacAxisThe axis along which the page view scrolls. Defaults to Axis.horizontal.
reverseboolWhether the page view scrolls in the reverse direction. Defaults to false.
physicsStacScrollPhysicsThe physics for the scroll view.
pageSnappingboolWhether the page view should snap to page boundaries. Defaults to true.
onPageChangedStacActionThe callback that is called when the page changes.
dragStartBehaviorStacDragStartBehaviorThe drag start behavior. Defaults to DragStartBehavior.start.
allowImplicitScrollingboolWhether to allow implicit scrolling. Defaults to false.
restorationIdStringThe restoration ID to save and restore the scroll offset.
clipBehaviorStacClipThe clip behavior of the page view. Defaults to Clip.hardEdge.
padEndsboolWhether to pad the ends of the page view. Defaults to true.
initialPageintThe initial page to show. Defaults to 0.
keepPageboolWhether to save the current page. Defaults to true.
viewportFractiondoubleThe fraction of the viewport that each page should occupy. Defaults to 1.0.
childrenList<StacWidget>The widgets below this widget in the tree. Defaults to an empty list.

Example

StacPageView(
  children: [
    StacContainer(
      color: StacColors.grey,
      child: StacCenter(
        child: StacText(
          data: 'Page 1',
          style: StacTextStyle(fontSize: 23, fontWeight: StacFontWeight.w400),
        ),
      ),
    ),
    StacContainer(
      color: StacColors.orange,
      child: StacCenter(
        child: StacText(
          data: 'Page 2',
          style: StacTextStyle(fontSize: 23, fontWeight: StacFontWeight.w400),
        ),
      ),
    ),
    StacContainer(
      color: StacColors.grey,
      child: StacCenter(
        child: StacText(
          data: 'Page 3',
          style: StacTextStyle(fontSize: 23, fontWeight: StacFontWeight.w400),
        ),
      ),
    ),
  ],
)