# Banner Cache

### Create placement <a href="#markdown-header-creating-placement" id="markdown-header-creating-placement"></a>

Create `BannerCacheConfiguration` object and call `BannerCache.create` method to create banner cache:

```dart
final bannerCacheConfiguration = BannerCacheConfiguration(
  "BannerCacheFlutter",
  size: 2,
  listener: CacheListener(
    firstBannerLoaded: () =>
        print("[BannerCacheFlutter] firstBannerLoaded"),
  ),
);
_bannerCache =
    await BannerCache.create(configuration: bannerCacheConfiguration);
```

### Consume Banners

Next banner is consumed automatically when adding `AATKitCachedBanner` widget with passed `BannerCache` object as a parameter:

```dart
AATKitCachedBanner(
  bannerCache: _bannerCache,
  key: UniqueKey(),
)
```

### Destroy old banner

Banner is destroyed automatically when `AATKitBanner` widget is no longer attached to the UI.

### Destroy no longer needed BannerCache <a href="#markdown-header-destroy-no-longer-needed-bannercache" id="markdown-header-destroy-no-longer-needed-bannercache"></a>

For proper memory management, `BannerCache` needs to be destroyed when is no longer needed. The `destroy` method destroys the `BannerCache`:

```dart
_bannerCache.destroy();
```


---

# 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://aatkit.gitbook.io/aatkit-flutter-integration/formats/banner-cache.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.
