> ## Documentation Index
> Fetch the complete documentation index at: https://beta-guide.daro.so/llms.txt
> Use this file to discover all available pages before exploring further.

# App Open Ads

> Implement app open ads with the DARO Flutter SDK.

## App Open Ad Format

* Full-screen ads displayed when the app launches or returns to the foreground.
* Naturally displayed on app loading or splash screens.

***

## Creating Instance and Setting Callbacks

Create a `DaroAppOpenAd` instance and set up callbacks.

```dart theme={null}
import 'package:daro_flutter/daro_flutter.dart';
```

```dart theme={null}
final appOpenAd = DaroAppOpenAd(adUnitId: '{YOUR_AD_UNIT_ID}');

appOpenAd.onAdLoadSuccess = (adInfo) {
  print('App open ad loaded');
};
appOpenAd.onAdLoadFail = (error) {
  print('App open ad failed to load: ${error.message}');
};
appOpenAd.onAdImpression = (adInfo) {
  print('App open ad impression');
};
appOpenAd.onAdClicked = (adInfo) {
  print('App open ad clicked');
};
appOpenAd.onAdShown = (adInfo) {
  print('App open ad shown');
};
appOpenAd.onAdFailedToShow = (error) {
  print('App open ad failed to show: ${error.message}');
};
appOpenAd.onAdDismiss = (adInfo) {
  print('App open ad dismissed');
};
```

## Loading Ads

Call `load()` to load an ad.

```dart theme={null}
appOpenAd.load();
```

## Showing Ads

Check if the ad is ready with `isReady()`, then display it with `show()`.

```dart theme={null}
final isReady = await appOpenAd.isReady();

if (isReady) {
  appOpenAd.show();
}
```

## Releasing Resources

Call `dispose()` to release resources when done.

```dart theme={null}
appOpenAd.dispose();
```

### Implementation Example

<Accordion title="This is an example implementation of `DaroAppOpenAd`." icon="sparkles">
  ```dart theme={null}
  import 'package:flutter/material.dart';
  import 'package:daro_flutter/daro_flutter.dart';

  class AppOpenAdPage extends StatefulWidget {
    const AppOpenAdPage({super.key});

    @override
    State<AppOpenAdPage> createState() => _AppOpenAdPageState();
  }

  class _AppOpenAdPageState extends State<AppOpenAdPage> with WidgetsBindingObserver {
    late final DaroAppOpenAd _appOpenAd;
    String _status = 'Not Loaded';

    @override
    void initState() {
      super.initState();
      WidgetsBinding.instance.addObserver(this);
      _appOpenAd = DaroAppOpenAd(adUnitId: '{YOUR_AD_UNIT_ID}');
      _setupCallbacks();
    }

    void _setupCallbacks() {
      _appOpenAd.onAdLoadSuccess = (adInfo) {
        setState(() => _status = 'Loaded');
      };

      _appOpenAd.onAdLoadFail = (error) {
        setState(() => _status = 'Failed to Load');
      };

      _appOpenAd.onAdShown = (adInfo) {
        setState(() => _status = 'Shown');
      };

      _appOpenAd.onAdFailedToShow = (error) {
        setState(() => _status = 'Failed to Show');
      };

      _appOpenAd.onAdDismiss = (adInfo) {
        setState(() => _status = 'Not Loaded');
        // Reload after ad is dismissed
        _appOpenAd.load();
      };

      _appOpenAd.onAdClicked = (adInfo) {
        print('App open ad clicked');
      };

      _appOpenAd.onAdImpression = (adInfo) {
        print('App open ad impression');
      };
    }

    @override
    void didChangeAppLifecycleState(AppLifecycleState state) {
      if (state == AppLifecycleState.resumed) {
        _showAppOpenAd();
      }
    }

    Future<void> _showAppOpenAd() async {
      final isReady = await _appOpenAd.isReady();
      if (isReady) {
        _appOpenAd.show();
      }
    }

    @override
    void dispose() {
      WidgetsBinding.instance.removeObserver(this);
      _appOpenAd.dispose();
      super.dispose();
    }

    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(title: const Text('App Open Ad')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Status: $_status'),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () {
                  setState(() => _status = 'Loading...');
                  _appOpenAd.load();
                },
                child: const Text('Load App Open Ad'),
              ),
              const SizedBox(height: 8),
              ElevatedButton(
                onPressed: () async {
                  final isReady = await _appOpenAd.isReady();
                  if (isReady) {
                    _appOpenAd.show();
                  }
                },
                child: const Text('Show App Open Ad'),
              ),
            ],
          ),
        ),
      );
    }
  }
  ```
</Accordion>
