> ## 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.

# SliverPadding

> Documentation for SliverPadding

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

export const sliverPaddingPreviewJson = {
  "type": "scaffold",
  "body": {
    "type": "customScrollView",
    "slivers": [{
      "type": "sliverPadding",
      "padding": 16,
      "sliver": {
        "type": "sliverToBoxAdapter",
        "child": {
          "type": "container",
          "height": 150,
          "color": "#4CAF50",
          "child": {
            "type": "center",
            "child": {
              "type": "text",
              "data": "I am a Box inside a SliverPadding!",
              "style": {
                "color": "#FFFFFF",
                "fontWeight": "bold"
              }
            }
          }
        }
      }
    }]
  }
};
export const sliverPaddingPreviewSrc = `${PLAYGROUND_BASE_URL}/embed`;

The Stac SliverPadding allows you to inset a sliver widget by a given padding using JSON. It is typically used inside a `CustomScrollView`.
To know more about the sliver padding widget in Flutter, refer to
the [official documentation](https://api.flutter.dev/flutter/widgets/SliverPadding-class.html).

## Properties

| Property | Type                   | Description                                      |
| -------- | ---------------------- | ------------------------------------------------ |
| padding  | `Map<String, dynamic>` | The amount of space by which to inset the child. |
| sliver   | `Map<String, dynamic>` | The sliver widget inside the padding.            |

## Example

<Tabs sync={false}>
  <Tab title="Dart">
    ```dart theme={null}
    StacSliverPadding(
      padding: StacEdgeInsets.all(16.0),
      sliver: StacSliverToBoxAdapter(
        child: StacContainer(
          height: 150,
          color: StacColors.green,
          child: StacCenter(
            child: StacText(
              data: 'I am a Box inside a SliverPadding!',
              style: StacTextStyle(color: StacColors.white, fontWeight: StacFontWeight.bold),
            ),
          ),
        ),
      ),
    )
    ```
  </Tab>

  <Tab title="JSON">
    ```json theme={null}
    {
      "type": "scaffold",
      "body": {
        "type": "customScrollView",
        "slivers": [
          {
            "type": "sliverPadding",
            "padding": 16,
            "sliver": {
              "type": "sliverToBoxAdapter",
              "child": {
                "type": "container",
                "height": 150,
                "color": "#4CAF50",
                "child": {
                  "type": "center",
                  "child": {
                    "type": "text",
                    "data": "I am a Box inside a SliverPadding!",
                    "style": {
                      "color": "#FFFFFF",
                      "fontWeight": "bold"
                    }
                  }
                }
              }
            }
          }
        ]
      }
    }
    ```
  </Tab>

  <Tab title="Preview">
    <Frame>
      <iframe
        id="stac"
        src={sliverPaddingPreviewSrc}
        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: sliverPaddingPreviewJson
      };

      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>
