> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stac.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# CustomScrollView

> Documentation for CustomScrollView

export const PLAYGROUND_BASE_URL = "https://playground.stac.dev/";

export const customScrollViewPreviewJson = {
  "type": "customScrollView",
  "slivers": [{
    "type": "sliverAppBar",
    "title": {
      "type": "text",
      "data": "SliverAppBar"
    },
    "leading": {
      "type": "iconButton",
      "icon": {
        "type": "icon",
        "iconType": "material",
        "icon": "menu"
      },
      "onPressed": {}
    },
    "backgroundColor": "primary"
  }]
};
export const customScrollViewPreviewSrc = `${PLAYGROUND_BASE_URL}/embed`;

The Stac CustomScrollView allows you to build a Flutter CustomScrollView widget using JSON.
To know more about the CustomScrollView widget in Flutter, refer to
the [official documentation](https://api.flutter.dev/flutter/widgets/CustomScrollView-class.html).

## Properties

| Property                | Type                                    | Description                                                                                                         |
| ----------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| slivers                 | `List<StacWidget>`                      | The slivers to place inside the viewport.                                                                           |
| scrollDirection         | `StacAxis`                              | The axis along which the scroll view scrolls. Defaults to `Axis.vertical`.                                          |
| reverse                 | `bool`                                  | Whether the scroll view scrolls in the reverse direction. Defaults to `false`.                                      |
| padding                 | `StacEdgeInsets`                        | The amount of space by which to inset the child.                                                                    |
| primary                 | `bool`                                  | Whether this is the primary scroll view associated with the parent.                                                 |
| physics                 | `StacScrollPhysics`                     | How the scroll view should respond to user input.                                                                   |
| dragStartBehavior       | `StacDragStartBehavior`                 | Determines the way that drag start behavior is handled. Defaults to `DragStartBehavior.start`.                      |
| clipBehavior            | `StacClip`                              | The content will be clipped (or not) according to this option. Defaults to `Clip.hardEdge`.                         |
| restorationId           | `String`                                | The restoration ID to save and restore the state of the scroll view.                                                |
| keyboardDismissBehavior | `StacScrollViewKeyboardDismissBehavior` | Configures how the scroll view should dismiss the keyboard. Defaults to `ScrollViewKeyboardDismissBehavior.manual`. |

## Example

<Tabs sync={false}>
  <Tab title="Dart">
    ```dart theme={null}
    StacCustomScrollView(
      slivers: [
        StacSliverAppBar(
          title: StacText(data: 'SliverAppBar'),
          leading: StacIconButton(
            icon: StacIcon(iconType: 'material', icon: 'menu'),
            onPressed: {},
          ),
          backgroundColor: 'primary',
        ),
      ],
    )
    ```
  </Tab>

  <Tab title="JSON">
    ```json theme={null}
    {
      "type": "customScrollView",
      "slivers": [
        {
          "type": "sliverAppBar",
          "title": {
            "type": "text",
            "data": "SliverAppBar"
          },
          "leading": {
            "type": "iconButton",
            "icon": {
              "type": "icon",
              "iconType": "material",
              "icon": "menu"
            },
            "onPressed": {}
          },
          "backgroundColor": "primary"
        }
      ]
    }
    ```
  </Tab>

  <Tab title="Preview">
    <Frame>
      <iframe
        id="stac"
        src={customScrollViewPreviewSrc}
        title="Stac Playground"
        className="w-full rounded-xl border-0"
        style={{ height: "640px" }}
        loading="lazy"
        onLoad={(event) => {
      const iframe = event.currentTarget;
      const targetOrigin = PLAYGROUND_BASE_URL;
      const message = {
        type: "stac-preview-json",
        payload: customScrollViewPreviewJson
      };

      let attempts = 0;
      const maxAttempts = 12;
      const interval = setInterval(() => {
        iframe.contentWindow?.postMessage(message, targetOrigin);
        attempts += 1;

        if (attempts >= maxAttempts) {
          clearInterval(interval);
        }
      }, 250);
    }}
      />
    </Frame>
  </Tab>
</Tabs>
