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

# Rewarded Video Ads

> Implement rewarded video ads with the DARO Flutter SDK.

## Rewarded Video Ad Format

* Ads that provide in-app rewards (currency, features, content, etc.) in exchange for watching.
* Since users watch in exchange for rewards, video ads cannot be skipped and typically run for 30 seconds.

<img src="https://mintcdn.com/delightroom-daro-beta/Cj5gm0YF3Gn_WtLl/sdk-integration/common-img/ad-formats-en/rv-example-image.png?fit=max&auto=format&n=Cj5gm0YF3Gn_WtLl&q=85&s=a4beded0bdd53e0ccf442663d4245c3e" alt="Rv Example Image Pn" title="Rv Example Image Pn" style={{ width:"40%" }} width="720" height="1560" data-path="sdk-integration/common-img/ad-formats-en/rv-example-image.png" />

### How It Works

<img src="https://mintcdn.com/delightroom-daro-beta/Cj5gm0YF3Gn_WtLl/sdk-integration/common-img/ad-formats-en/rv-example-gif.gif?s=302a03fd9fe48d45f15c5e3147c4de92" alt="Rv Example Gif Gi" title="Rv Example Gif Gi" style={{ width:"40%" }} width="180" height="390" data-path="sdk-integration/common-img/ad-formats-en/rv-example-gif.gif" />

***

## Creating Instance and Setting Callbacks

Create a `DaroRewardedAd` instance and set up callbacks.

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

```dart theme={null}
final rewardedAd = DaroRewardedAd(adUnitId: '{YOUR_AD_UNIT_ID}');

rewardedAd.onAdLoadSuccess = (adInfo) {
  print('Rewarded ad loaded');
};
rewardedAd.onAdLoadFail = (error) {
  print('Rewarded ad failed to load: ${error.message}');
};
rewardedAd.onAdImpression = (adInfo) {
  print('Rewarded ad impression');
};
rewardedAd.onAdClicked = (adInfo) {
  print('Rewarded ad clicked');
};
rewardedAd.onAdShown = (adInfo) {
  print('Rewarded ad shown');
};
rewardedAd.onAdFailedToShow = (error) {
  print('Rewarded ad failed to show: ${error.message}');
};
rewardedAd.onAdDismiss = (adInfo) {
  print('Rewarded ad dismissed');
};
rewardedAd.onEarnedReward = (adInfo, rewardItem) {
  print('Earned reward: ${rewardItem.amount} ${rewardItem.type}');
};
```

### Reward Callback

The `onEarnedReward` callback is triggered when the user watches the ad to completion and earns a reward. You can access the reward details through `DaroRewardItem`.

| Property | Description     |
| -------- | --------------- |
| `amount` | Reward quantity |
| `type`   | Reward type     |

## Loading Ads

Call `load()` to load an ad.

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

## Setting Custom Data

Use `setCustomData()` to set custom data to be included in S2S (Server-to-Server) reward callbacks. This must be set before calling `show()`.

```dart theme={null}
await rewardedAd.setCustomData('your_custom_data');
```

## Showing Ads

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

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

if (isReady) {
  await rewardedAd.setCustomData('your_custom_data');
  rewardedAd.show();
}
```

## Releasing Resources

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

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

### Implementation Example

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

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

    @override
    State<RewardedAdPage> createState() => _RewardedAdPageState();
  }

  class _RewardedAdPageState extends State<RewardedAdPage> {
    late final DaroRewardedAd _rewardedAd;
    String _status = 'Not Loaded';

    @override
    void initState() {
      super.initState();
      _rewardedAd = DaroRewardedAd(adUnitId: '{YOUR_AD_UNIT_ID}');
      _setupCallbacks();
    }

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

      _rewardedAd.onAdLoadFail = (error) {
        setState(() => _status = 'Failed to Load');
        print('Rewarded ad failed to load: ${error.message}');
      };

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

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

      _rewardedAd.onAdDismiss = (adInfo) {
        setState(() => _status = 'Not Loaded');
      };

      _rewardedAd.onAdClicked = (adInfo) {
        print('Rewarded ad clicked');
      };

      _rewardedAd.onAdImpression = (adInfo) {
        print('Rewarded ad impression');
      };

      _rewardedAd.onEarnedReward = (adInfo, rewardItem) {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text('Reward: ${rewardItem.amount} ${rewardItem.type}')),
        );
      };
    }

    @override
    void dispose() {
      _rewardedAd.dispose();
      super.dispose();
    }

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