# Interstitial, Open and Rewarded

### loadAd(adId, callbackEvent)

Load PubStar ads by `Advertisement Id` to application.

### Event

`LoadListener`

| Callback   | Function                                                    |
| ---------- | ----------------------------------------------------------- |
| `onError`  | call when load ad failed. return object type `PubstarError` |
| `onLoaded` | call when ad loaded                                         |

### Example

```dart
PubstarIo.loadAd(
  adId,
  LoadListener(
    onLoaded: () {
        // callback when ad loaded
    },
    onError:
        (error) {
            // callback when ad load error
        },
  ),
);
```

## showAd(adId, callbackEvent)

Show ad had loaded before.

### Event

`ShowListener`

| Callback   | Function                                                                                                        |
| ---------- | --------------------------------------------------------------------------------------------------------------- |
| `onHide`   | call when ad hidden/closed (supports rewarded ads). Returns detailed `PubstarReward` object (`type`, `amount`). |
| `onShowed` | call when ad showed                                                                                             |
| `onError`  | call when show ad failed. return object type `PubstarError`                                                     |

### Example

```dart
PubstarIo.showAd(
  adId,
  ShowListener(
    onShowed: () {
        // callback when ad showed
    },
    onHide:
        (reward) {
            // callback when ad hide with reward option
        },
    onError:
        (error) {
            // callback when error
        },
  ),
);
```

## loadAndShow(adId, callbackEvent)

Load and immediately show an ad by ID.

### Event

LoadAndShowNoViewListener

| Callback   | Function                                                                                                        |
| ---------- | --------------------------------------------------------------------------------------------------------------- |
| `onLoaded` | call when ad loaded                                                                                             |
| `onShowed` | call when ad showed                                                                                             |
| `onHide`   | call when ad hidden/closed (supports rewarded ads). Returns detailed `PubstarReward` object (`type`, `amount`). |
| `onError`  | call when show ad failed. return object type `PubstarError`                                                     |

### Example

```dart
PubstarIo.loadAndShow(
  adId,
  LoadAndShowNoViewListener(
    onError:
        (error) {
            // callback when ads error
        },
    onHide:
        (reward) {
            // callback when ad hide with reward option
        },
    onLoaded: () {
        // callback when ad loaded
    },
    onShowed: () {
        // callback when ad showed
    },
  ),
);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pub-star.gitbook.io/docs/1.5.0/flutter-sdk/ads-with-no-view.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
