# 5-2. Interstitial Ads for Flutter

### Before you begin

{% content-ref url="" %}
[](https://one-admax-organization.gitbook.io/one-admax-sdk/oneadmax_dev_guide_en/05.-flutter-plugin-guide)
{% endcontent-ref %}

### Creating an instance of Interstitial Ads.

```java
 ...
 OAMInterstitial _oamInterstitial = OAMInterstitial()
 ...
```

### Request an interstitial ad.

A request is made to `load()` interstitial ad.\
The parameters are `placementId` and `InterstitialCallBackListener`.\\

[The `placementId` for the interstitial ad can be created in the ONE AdMax console.](https://one-admax-organization.gitbook.io/one-admax-sdk/oneadmax_dev_guide_en/02.-how-to-issue-a-placement-key)

```dart
oamInterstitial.load(
 placementId: interstitialPlacementId,
);
```

{% hint style="danger" %}
Excessive calls to the `load()` API may result in being blocked.
{% endhint %}

### Set the event listener for the interstitial ad.

Set a listener for events that occur when loading a interstial ad.

```java
_oamInterstitial.load(
  callback: InterstitialCallBackListener(
    onLoaded: onLoaded,
    onLoadFailed: onLoadFailed,
    onOpened: onOpened,
    onOpenFailed: onOpenFailed,
    onClosed: onClosed,
    onClicked: onClicked,
  ),
);
```

{% content-ref url="../oamerror" %}
[oamerror](https://one-admax-organization.gitbook.io/one-admax-sdk/oneadmax_dev_guide_en/oamerror)
{% endcontent-ref %}

### Display the interstitial ad <a href="#display-the-interstitial-a-d" id="display-the-interstitial-a-d"></a>

```java
_oamInterstitial.show();
```

### Custom options for interstitial ads.

| 변수                    | 설명                                                                                            |
| --------------------- | --------------------------------------------------------------------------------------------- |
| backgroundColor       | Change background color and transparency. Use a `Color` value.                                |
| isHideCloseButton     | <p>Set whether to display the close button in the top-right corner.</p><p>default : false</p> |
| closeBtnMargin.left   | <p>Left margin of the close button.</p><p>default : 28dp</p>                                  |
| closeBtnMargin.top    | <p>Top margin of the close button.</p><p>default : 20dp</p>                                   |
| closeBtnMargin.right  | <p>Right margin of the close button.. </p><p>default : 20dp</p>                               |
| closeBtnMargin.bottom | <p>Bottom margin of the close button. </p><p>default : 0dp</p>                                |
| isDisableBackButton   | <p>Do not use the back button to close.. </p><p>deault : false</p>                            |
| EndingText.isShow     | Whether to display the ending message. default : false                                        |
| EndingText.text       | <p>Ending message. <br>default : "뒤로 가기를 한 번 더 누르시면 종료됩니다."</p>                               |
| EndingText.size       | <p>Ending message size. </p><p>default : 11sp</p>                                             |
| EndingText.color      | <p>Ending message test color. </p><p>default : white</p>                                      |
| EndingText.align      | <p>Ending message gravity. </p><p>default : Right</p>                                         |

### Sample code for interstitial ads.

```java
OAMInterstitial _oamInterstitial = OAMInterstitial()

_oamInterstitial.load(
  placementId: interstitialPlacementId,
  callback: InterstitialCallBackListener(
    onLoaded: onLoaded,
    onLoadFailed: onLoadFailed,
    onOpened: onOpened,
    onOpenFailed: onOpenFailed,
    onClosed: onClosed,
    onClicked: onClicked,
  ),
);

_oamInterstitial.interstitialConfig.isHideCloseButton = false;
_oamInterstitial.interstitialConfig.backgroundColor = Colors.red;
_oamInterstitial.interstitialConfig.endingText = const EndingText(
  'Sample Text',
  12,
  Colors.white,
  TextAlign.center,
  true,
);

_oamInterstitial.interstitialConfig.closeBtnMargin = const CloseBtnMargin(
  top: 10,
  left: 10,
  right: 10,
  bottom: 10,
);

_oamInterstitial.show();
```
