nooralibutt / easy-ads

This repo has the integration of AdMob, AppLovin-Max, UnityAds, and Facebook ads.
https://pub.dev/packages/easy_ads_flutter
BSD 3-Clause "New" or "Revised" License
41 stars 20 forks source link

Event management #13

Closed nooralibutt closed 3 years ago

nooralibutt commented 3 years ago

Add event management for ad loaded, failed, displayed, etc callbacks using streams

for example:

enum AdEventType {loaded, failedToLoad, etc}
class AdEvent {
    final AdEventType type;
    final String? error;
    final Object? data;
    final AdNetwork;
    final AdUnitType;
}
final _onEventController = StreamController< AdEvent >.broadcast();

/// The events this ad throws. Listen to it using:
///
/// ```dart
/// ad.onEvent.listen((event) {
///   print(event);
/// });
/// ```
Stream< AdEvent > get onEvent => onEventController.stream;

/// to fire an event use:
_onEventController.add(AdEvent);