Skip to main content

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.
Rv Example Image Pn

How It Works

Rv Example Gif Gi

Creating Instance and Setting Callbacks

Create a DaroRewardedAd instance and set up callbacks.
import 'package:daro_flutter/daro_flutter.dart';
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.
PropertyDescription
amountReward quantity
typeReward type

Loading Ads

Call load() to load an ad.
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().
await rewardedAd.setCustomData('your_custom_data');

Showing Ads

Check if the ad is ready with isReady(), then display it with show().
final isReady = await rewardedAd.isReady();

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

Releasing Resources

Call destroy() to release resources when done.
rewardedAd.destroy();

Implementation Example

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.destroy();
    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'),
            ),
          ],
        ),
      ),
    );
  }
}