refinery89_monetize_app 3.0.0 copy "refinery89_monetize_app: ^3.0.0" to clipboard
refinery89_monetize_app: ^3.0.0 copied to clipboard

The flutter plugin for the Refinery 89 Monetize App, supporting banner, outStream, interstitial (full-screen) and scrollable ads

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:refinery89_monetize_app/r89_sdk.dart';

void main() {
  runApp(const App());
}

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

  @override
  State<App> createState() => _AppState();
}

class _AppState extends State<App> {
  bool _isManualInitialized = false;
  bool _isAutomaticInitialized = false;
  bool _isInitializationInProgress = false;
  bool _isDisableCmpChecked = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorObservers: [R89SDK.routeObserver],
      home: Scaffold(
        body: Builder(
          builder: (BuildContext context) => Stack(
            children: [
              if (_isInitializationInProgress)
                const Center(
                    child: Card(
                      child: SizedBox(
                          width: 96,
                          height: 96,
                          child: CircularProgressIndicator()),
                    )),
              Align(
                alignment: Alignment.bottomCenter,
                child: Container(
                  width: double.infinity,
                  color: Colors.white,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      if (!_isManualInitialized &&
                          !_isAutomaticInitialized &&
                          !_isInitializationInProgress) ...[
                        Padding(
                          padding: const EdgeInsets.only(bottom: 48),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              const Text('Disable CMP  '),
                              Checkbox(
                                value: _isDisableCmpChecked,
                                onChanged: (value) => setState(() =>
                                _isDisableCmpChecked =
                                !_isDisableCmpChecked),
                              ),
                            ],
                          ),
                        ),
                        FilledButton(
                            onPressed: () {
                              // Initialize the SDK in debug mode
                              setState(() {
                                _isInitializationInProgress = true;
                              });
                              initializeInManualMode(
                                  context,
                                  InitializationEvents.callbacks(
                                      onInitializationFinishedCallback: () {
                                        setState(() {
                                          _isManualInitialized = true;
                                          _isInitializationInProgress = false;
                                        });
                                      }));
                            },
                            child: const Text('MANUAL CONFIG INITIALIZE')),
                        FilledButton(
                            onPressed: () {
                              // Initialize the SDK in debug mode
                              setState(() {
                                _isInitializationInProgress = true;
                              });
                              initializeInAutomaticMode(
                                  InitializationEvents.callbacks(
                                      onInitializationFinishedCallback: () {
                                        setState(() {
                                          _isAutomaticInitialized = true;
                                          _isInitializationInProgress = false;
                                        });
                                      }));
                            },
                            child: const Text('SINGLE TAG INITIALIZE')),
                      ],
                      if (_isAutomaticInitialized)
                        const Flexible(child: AutomaticInitializationContent()),
                      if (_isManualInitialized)
                        const Flexible(child: ManualInitializationContent()),
                    ],
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }

  /// Initializes the SDK in a manual mode, see [R89SDK.initialize]
  void initializeInManualMode(BuildContext context,InitializationEvents listener) async {
    if (_isDisableCmpChecked) {
      await R89SDK.disableCMP();
    }
    await R89SDK.setLogLevel(LogLevel.verbose);
    await R89SDK.setDebug();
    await R89SDK.initialize(
        pubUUID: "TestRefineryPubUUID",
        apiKey: "TestRefineryPubUUID",
        singleTag: false,
        initializationEvents: listener);
    R89SDK.adFactory.subscribeToAppOpen(
      AppOpenInterstitialEventListener.callbacks(
        onLoadedCallback: () {
          showAdSnackBar(context, 'App Open loaded');
        },
        onFailedToLoadCallback: (message) {
          showAdSnackBar(
            context,
            'Failed to load App Open: $message',
          );
        },
        onOpenCallback: () {
          showAdSnackBar(context, 'App Open opened');
        },
        onImpressionCallback: () {
          showAdSnackBar(context, 'App Open impression');
        },
        onClickCallback: () {
          showAdSnackBar(context, 'App Open clicked');
        },
        onAdFailedToShowFullScreenCallback: (message) {
          showAdSnackBar(
            context,
            'Failed to show interstitial fullscreen: $message',
          );
        },
        onAdDismissedFullScreenContentCallback: () {
          showAdSnackBar(context, 'App Open dismissed');
        },
      ),
    );
  }

  /// Initializes the SDK in a automatic mode, see [R89SDK.initialize],
  /// After initialization SDK will use R89Tag widgets to substitute ads.
  void initializeInAutomaticMode(InitializationEvents listener) async {
    R89SDK.singleTagConfiguration
      ..initialRouteName = '/'
      ..addAdScreenConfig(
          adScreenConfig: AdScreenConfig(screenName: '/')
          // This configs a banner ad to be substituted in all places (because getAllWithTag:true)
          // where R89Tag with 'banner_tag' is specified in the 'BannerTagsScreen'
            ..addBanner(
                tag: 'banner_tag',
                getAllWithTag: true,
                wrapperRelativePositionAfter: true)
          // This configs a outstream ad to be substituted for the first (because getAllWithTag:false)
          // R89Tag with 'outstream_tag' is specified.
            ..addOutStream(
                tag: 'outstream_tag',
                getAllWithTag: false,
                wrapperRelativePositionAfter: true)
          // This configs a the BannerTagsScreen's close button to display an interstitial before
          // handling the close action, for that the close button need to be wrapped in R89Tag
          // with tag specified as 'close_button_tag'
            ..addInterstitial(eventToTrackButton: 'button_tag')
          // This configs an interstitial ad to be displayed when navigating to BannerTagsScreen
          // from the root '/' screen.
            ..addInterstitial(eventToTrack: 'FeaturesList'))
      ..addAdScreenConfig(
        adScreenConfig: AdScreenConfig(screenName: 'FeaturesList')
          ..addInfiniteScroll(tag: 'scroll_tag')
          ..addInterstitial(eventToTrack: '/'),
      );

    if (_isDisableCmpChecked) {
      await R89SDK.disableCMP();
    }
    await R89SDK.setLogLevel(LogLevel.verbose);
    await R89SDK.setDebug();
    await R89SDK.initialize(
        pubUUID: "TestRefinery89ID",
        apiKey: "TestDemoApp",
        singleTag: true,
        initializationEvents: listener);
  }
}

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

  @override
  State<ManualInitializationContent> createState() =>
      _ManualInitializationContentState();
}

class _ManualInitializationContentState
    extends State<ManualInitializationContent> {
  bool _isBannerEnabled = false;
  bool _isOutstreamEnabled = false;
  bool _appOpenEnabled = true;

  int? _bannerInterstitialId;
  int? _videoInterstitialId;
  int? _rewardedId;
  int? _rewardedInterstitialId;

  @override
  Widget build(BuildContext context) => StreamBuilder<Object>(
      stream: null,
      builder: (context, snapshot) {
        return Stack(
          alignment: Alignment.bottomCenter,
          children: [
            Align(
              alignment: Alignment.topCenter,
              child: ListView(
                padding: EdgeInsets.only(
                    left: 24,
                    right: 24,
                    bottom: MediaQuery.of(context).size.height / 2),
                children: [
                  const SizedBox(
                    height: 48,
                  ),
                  FilledButton(
                      onPressed: () async => showAdSnackBar(
                          context, '${await R89SDK.getInitializationState()}'),
                      child: const Text('CHECK INITIALIZATION STATE')),
                  FilledButton(
                      onPressed: () async => showAdSnackBar(
                          context, 'isDebug: ${await R89SDK.isDebug()}'),
                      child: const Text('CHECK IS DEBUG')),
                  const SizedBox(
                    height: 24,
                  ),
                  FilledButton(
                      onPressed: () => _showAddOnAdFor(banner: true),
                      child: const Text('SHOW BANNER')),
                  FilledButton(
                      onPressed: () => _showAddOnAdFor(outstream: true),
                      child: const Text('SHOW VIDEO BANNER')),
                  const SizedBox(
                    height: 48,
                  ),
                  FilledButton(
                      onPressed: () {
                        final int infiniteScrollId = R89SDK.adFactory
                            .createInfiniteScroll(
                            configurationId: ConfigBuilder
                                .infiniteScrollTestR89ConfigId);
                        Navigator.of(context).push(MaterialPageRoute(
                          builder: (context) => Scaffold(
                            appBar: AppBar(
                              title: const Text('INFINITE SCROLL'),
                            ),
                            body: _infiniteScroll(context, infiniteScrollId),
                          ),
                        ));
                      },
                      child: const Text('SHOW INFINITE SCROLL')),
                  const SizedBox(
                    height: 48,
                  ),
                  FilledButton(
                      onPressed: () async {
                        var interstitialId = -1;
                        showAdSnackBar(
                          context,
                          'Interstitial: Loading...',
                        );
                        interstitialId =
                        await R89SDK.adFactory.createInterstitial(
                          configurationId:
                          ConfigBuilder.interstitialTestR89ConfigId,
                          onComplete: () {
                            showAdSnackBar(context, 'Interstitial after dismissal');
                          },
                          lifecycleCallbacks:
                          InterstitialEventListener.callbacks(
                            onLoadedCallback: () {
                              showAdSnackBar(context, 'Interstitial loaded');
                              setState(() {
                                _bannerInterstitialId = interstitialId;
                              });
                            },
                            onOpenCallback: () {
                              showAdSnackBar(context, 'Interstitial opened');
                            },
                            onImpressionCallback: () {
                              showAdSnackBar(
                                  context, 'Interstitial impression recorded');
                            },
                            onClickCallback: () {
                              showAdSnackBar(context, 'Interstitial clicked');
                            },
                            onFailedToLoadCallback: (message) {
                              showAdSnackBar(context,
                                  'Failed to load interstitial: $message');
                            },
                            onAdFailedToShowFullScreenCallback: (message) {
                              showAdSnackBar(
                                context,
                                'Failed to show interstitial fullscreen: $message',
                              );
                              setState(() {
                                _bannerInterstitialId = null;
                              });
                            },
                            onAdDismissedFullScreenContentCallback: () {
                              showAdSnackBar(
                                context,
                                'Interstitial ad closed',
                              );
                              setState(() {
                                _bannerInterstitialId = null;
                              });
                            },
                          ),
                        );
                      },
                      child: const Text('LOAD BANNER INTERSTITIAL AD')),
                  if(_bannerInterstitialId case int bannerInterstitialId)
                    ...[
                      FilledButton(
                          onPressed: () => R89SDK.adFactory.show(bannerInterstitialId),
                          child: const Text('SHOW BANNER INTERSTITIAL AD')),
                      const SizedBox(height: 16,),
                    ],
                  FilledButton(
                      onPressed: () async {
                        var interstitialId = -1;
                        showAdSnackBar(
                          context,
                          'Interstitial: Loading...',
                        );
                        interstitialId =
                        await R89SDK.adFactory.createInterstitial(
                          configurationId:
                          ConfigBuilder.videoInterstitialTestR89ConfigId,
                          onComplete: () {
                            showAdSnackBar(context, 'Interstitial after dismissal');
                          },
                          lifecycleCallbacks:
                          InterstitialEventListener.callbacks(
                              onLoadedCallback: () {
                                showAdSnackBar(context, 'Interstitial loaded');
                                setState(() {
                                  _videoInterstitialId = interstitialId;
                                });
                              }, onOpenCallback: () {
                            showAdSnackBar(context, 'Interstitial opened');
                          }, onImpressionCallback: () {
                            showAdSnackBar(
                                context, 'Interstitial impression recorded');
                          }, onClickCallback: () {
                            showAdSnackBar(context, 'Interstitial clicked');
                          }, onFailedToLoadCallback: (message) {
                            showAdSnackBar(context,
                                'Failed to load interstitial: $message');
                          }, onAdFailedToShowFullScreenCallback: (message) {
                            showAdSnackBar(
                              context,
                              'Failed to show interstitial fullscreen: $message',
                            );
                            setState(() {
                              _videoInterstitialId = null;
                            });
                          }, onAdDismissedFullScreenContentCallback: () {
                            showAdSnackBar(
                              context,
                              'Interstitial ad closed',
                            );
                            setState(() {
                              _videoInterstitialId = null;
                            });
                          }),
                        );
                      },
                      child: const Text('LOAD VIDEO INTERSTITIAL AD')),
                  if(_videoInterstitialId case int videoInterstitialId)
                    ...[
                      FilledButton(
                          onPressed: () => R89SDK.adFactory.show(videoInterstitialId),
                          child: const Text('SHOW VIDEO INTERSTITIAL AD')),
                      const SizedBox(height: 16,),
                    ],
                  FilledButton(
                    onPressed: () async {
                      var rewardedId = -1;
                      showAdSnackBar(
                        context,
                        'RewardedAd: Loading...',
                      );
                      rewardedId = await R89SDK.adFactory.createRewarded(
                        configurationId: ConfigBuilder.rewardedTestR89ConfigId,
                        onComplete: () {
                          showAdSnackBar(
                              context, 'RewardedAd: after rewarded callback');
                        },
                        rewardReceived: (reward) {
                          showAdSnackBar(
                            context,
                            'RewardedAd: reward received → amount=${reward.amount}, type=${reward.type}',
                          );
                        },
                        lifecycleCallbacks: RewardedEventListener.callbacks(
                          onLoadedCallback: () {
                            showAdSnackBar(context, 'RewardedAd: loaded');
                            setState(() {
                              _rewardedId = rewardedId;
                            });
                          },
                          onFailedToLoadCallback: (error) {
                            showAdSnackBar(
                              context,
                              'RewardedAd: failed to load → $error',
                            );
                          },
                          onImpressionCallback: () {
                            showAdSnackBar(
                                context, 'RewardedAd: impression recorded');
                          },
                          onClickCallback: () {
                            showAdSnackBar(context, 'RewardedAd: clicked');
                          },
                          onOpenCallback: () {
                            showAdSnackBar(
                                context, 'RewardedAd: opened (full screen)');
                          },
                          onAdFailedToShowFullScreenCallback: (error) {
                            showAdSnackBar(
                              context,
                              'RewardedAd: failed to show full screen → $error',
                            );
                            setState(() {
                              _rewardedId = null;
                            });
                          },
                          onRewardEarnedCallback: (amount, type) {
                            showAdSnackBar(
                              context,
                              'RewardedAd: reward earned → amount=$amount, type=$type',
                            );
                          },
                          onAdDismissedFullScreenContentCallback: () {
                            showAdSnackBar(
                                context, 'RewardedAd: dismissed full screen');
                            setState(() {
                              _rewardedId = null;
                            });
                          },
                        ),
                      );
                    },
                    child: const Text('LOAD REWARDED AD'),
                  ),
                  if(_rewardedId case int rewardedId)
                    ...[
                      FilledButton(
                          onPressed: () => R89SDK.adFactory.show(rewardedId),
                          child: const Text('SHOW REWARDED AD')),
                      const SizedBox(height: 16,),
                    ],
                  FilledButton(
                    onPressed: () async {
                      var rewardedInterstitialId = -1;
                      showAdSnackBar(
                        context,
                        'RewardedInterstitialAd: Loading...',
                      );
                      rewardedInterstitialId = await R89SDK.adFactory.createRewardedInterstitial(
                        configurationId: ConfigBuilder.rewardedInterstitialTestR89ConfigId,
                        onComplete: () {
                          showAdSnackBar(
                              context, 'RewardedInterstitialAd: after rewarded callback');
                        },
                        rewardReceived: (reward) {
                          showAdSnackBar(
                            context,
                            'RewardedInterstitialAd: reward received → amount=${reward.amount}, type=${reward.type}',
                          );
                        },
                        lifecycleCallbacks: RewardedEventListener.callbacks(
                          onLoadedCallback: () {
                            showAdSnackBar(context, 'RewardedInterstitialAd: loaded');
                            setState(() {
                              _rewardedInterstitialId = rewardedInterstitialId;
                            });
                          },
                          onFailedToLoadCallback: (error) {
                            showAdSnackBar(
                              context,
                              'RewardedInterstitialAd: failed to load → $error',
                            );
                          },
                          onImpressionCallback: () {
                            showAdSnackBar(
                                context, 'RewardedInterstitialAd: impression recorded');
                          },
                          onClickCallback: () {
                            showAdSnackBar(context, 'RewardedInterstitialAd: clicked');
                          },
                          onOpenCallback: () {
                            showAdSnackBar(
                                context, 'RewardedInterstitialAd: opened (full screen)');
                          },
                          onAdFailedToShowFullScreenCallback: (error) {
                            showAdSnackBar(
                              context,
                              'RewardedInterstitialAd: failed to show full screen → $error',
                            );
                            setState(() {
                              _rewardedInterstitialId = null;
                            });
                          },
                          onRewardEarnedCallback: (amount, type) {
                            showAdSnackBar(
                              context,
                              'RewardedInterstitialAd: reward earned → amount=$amount, type=$type',
                            );
                          },
                          onAdDismissedFullScreenContentCallback: () {
                            showAdSnackBar(
                                context, 'RewardedInterstitialAd: dismissed full screen');
                            setState(() {
                              _rewardedInterstitialId = null;
                            });
                          },
                        ),
                      );
                    },
                    child: const Text('LOAD REWARDED INTERSTITIAL AD'),
                  ),
                  if(_rewardedInterstitialId case int rewardedInterstitialId)
                    ...[
                      FilledButton(
                          onPressed: () => R89SDK.adFactory.show(rewardedInterstitialId),
                          child: const Text('SHOW REWARDED INTERSTITIAL AD')),
                      const SizedBox(height: 16,),
                    ],
                  const SizedBox(
                    height: 48,
                  ),
                  FilledButton(
                      style: ButtonStyle(
                          backgroundColor:
                          WidgetStateProperty.all(Colors.redAccent)),
                      onPressed: () => R89SDK.resetConsent(),
                      child: const Text('RESET CONSENT')),
                  FilledButton(
                      style: ButtonStyle(
                          backgroundColor:
                          WidgetStateProperty.all(Colors.redAccent)),
                      onPressed: () => R89SDK.reOpenConsent(),
                      child: const Text('RE OPEN CONSENT')),
                  FilledButton(
                      style: ButtonStyle(
                          backgroundColor:
                          WidgetStateProperty.all(Colors.redAccent)),
                      onPressed: () => R89SDK.shouldDisplayPrivacyOptions(
                            (privacyOptionsAreAvailable) {
                          showAdSnackBar(context,
                              "privacyOptionsAreAvailable=$privacyOptionsAreAvailable");
                        },
                      ),
                      child: const Text('SHOULD DISPLAY PRIVACY OPTIONS')),
                  FilledButton(
                      style: ButtonStyle(
                          backgroundColor:
                          WidgetStateProperty.all(Colors.redAccent)),
                      onPressed: () async {
                        String cmpString = await R89SDK.exportCmpString();
                        // Show the CMP string in a popup dialog
                        if (context.mounted) {
                          showDialog(
                            context: context,
                            builder: (BuildContext context) {
                              return AlertDialog(
                                content: SingleChildScrollView(
                                    child: SelectableText(cmpString)),
                                actions: <Widget>[
                                  TextButton(
                                    onPressed: () =>
                                        Navigator.of(context).pop(),
                                    child: const Text('Close'),
                                  ),
                                ],
                              );
                            },
                          );
                        }
                      },
                      child: const Text('EXPORT CMP STRING')),
                  FilledButton(
                      style: ButtonStyle(
                          backgroundColor:
                          WidgetStateProperty.all(Colors.redAccent)),
                      onPressed: () => _showAddOnAdFor(),
                      child: const Text('RESET ADS')),
                  const SizedBox(
                    height: 48,
                  ),
                  FilledButton(
                      onPressed: () {
                        showDialog(
                          context: context,
                          builder: (BuildContext context) {
                            return AlertDialog(
                              content: const SingleChildScrollView(
                                  child: Text(
                                      "Switching the application between background and foreground "
                                          "multiple times may trigger an App Open Ad upon returning to the app. "
                                          "\n\nThe ad’s lifecycle events will be displayed here "
                                          "in a Snackbar.")),
                              actions: <Widget>[
                                TextButton(
                                  onPressed: () => Navigator.of(context).pop(),
                                  child: const Text('OK'),
                                ),
                              ],
                            );
                          },
                        );
                        R89SDK.adFactory.subscribeToAppOpen(
                          AppOpenInterstitialEventListener.callbacks(
                            onLoadedCallback: () => showAdSnackBar(
                                context, "App Open Ad loaded successfully"),
                            onAdDismissedFullScreenContentCallback: () =>
                                showAdSnackBar(
                                  context,
                                  "App Open Ad dismissed full screen content",
                                ),
                            onAdFailedToShowFullScreenCallback: (errorMsg) =>
                                showAdSnackBar(
                                  context,
                                  "App Open Ad failed to show full screen: $errorMsg",
                                ),
                            onClickCallback: () =>
                                showAdSnackBar(context, "App Open Ad clicked"),
                            onFailedToLoadCallback: (error) => showAdSnackBar(
                              context,
                              "App Open Ad failed to load with error: $error",
                            ),
                            onImpressionCallback: () => showAdSnackBar(
                                context, "App Open Ad impression recorded"),
                            onOpenCallback: () =>
                                showAdSnackBar(context, "App Open Ad opened"),
                          ),
                        );
                      },
                      child: const Text('SUBSCRIBE APP OPEN EVENTS')),
                  FilledButton(
                      onPressed: () {
                        R89SDK.adFactory.subscribeToAppOpen(null);
                      },
                      child: const Text('UNSUBSCRIBE APP OPEN EVENTS')),
                  FilledButton(
                      onPressed: () async {
                        setState(() {
                          _appOpenEnabled = !_appOpenEnabled;
                        });
                        await R89SDK.adFactory
                            .setAppOpenEnabled(enabled: _appOpenEnabled);
                      },
                      child: Text(
                          'SET APP OPEN AD ${_appOpenEnabled ? 'DISABLED' : 'ENABLED'}'))
                ],
              ),
            ),
            if (_isOutstreamEnabled)
              R89OutStream(
                configurationId: ConfigBuilder.videoOutStreamTestR89ConfigId,
                lifecycleCallbacks: BannerEventListener.callbacks(
                  onLayoutChangeCallback: (width, height) {
                    showAdSnackBar(
                      context,
                      'Outstream layout changed → width=$width, height=$height',
                    );
                  },
                  onLoadedCallback: () {
                    showAdSnackBar(context, 'Outstream loaded');
                  },
                  onImpressionCallback: () {
                    showAdSnackBar(context, 'Outstream impression recorded');
                  },
                  onClickCallback: () {
                    showAdSnackBar(context, 'Outstream clicked');
                  },
                  onOpenCallback: () {
                    showAdSnackBar(
                        context, 'Outstream opened (full screen or expanded)');
                  },
                  onCloseCallback: () {
                    showAdSnackBar(context, 'Outstream closed');
                  },
                  onFailedToLoadCallback: (error) {
                    showAdSnackBar(
                      context,
                      'Outstream failed to load → $error',
                    );
                  },
                ),
              ),
            if (_isBannerEnabled)
              R89Banner(
                configurationId: ConfigBuilder.bannerTestR89ConfigId,
                lifecycleCallbacks: BannerEventListener.callbacks(
                  onLayoutChangeCallback: (width, height) {
                    showAdSnackBar(
                      context,
                      'Banner layout changed → width=$width, height=$height',
                    );
                  },
                  onLoadedCallback: () {
                    showAdSnackBar(context, 'Banner loaded');
                  },
                  onImpressionCallback: () {
                    showAdSnackBar(context, 'Banner impression recorded');
                  },
                  onClickCallback: () {
                    showAdSnackBar(context, 'Banner clicked');
                  },
                  onOpenCallback: () {
                    showAdSnackBar(
                        context, 'Banner opened (full screen or expanded)');
                  },
                  onCloseCallback: () {
                    showAdSnackBar(context, 'Banner closed');
                  },
                  onFailedToLoadCallback: (error) {
                    showAdSnackBar(
                      context,
                      'Banner failed to load → $error',
                    );
                  },
                ),
              ),
          ],
        );
      });

  Widget _infiniteScroll(BuildContext context, int infiniteScrollId) =>
      ListView.separated(
        itemCount: 100,
        separatorBuilder: (context, index) => const Divider(),
        itemBuilder: (context, index) => Column(
          children: [
            ListTile(
              leading: const Icon(
                Icons.star_rounded,
                color: Colors.amber,
              ),
              title: Text(features[index % features.length]),
            ),
            R89InfiniteScrollAd(
                infiniteScrollId: infiniteScrollId, itemIndex: index)
          ],
        ),
      );

  void _showAddOnAdFor({bool banner = false, bool outstream = false}) =>
      setState(() {
        _isOutstreamEnabled = outstream;
        _isBannerEnabled = banner;
      });
}

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

  @override
  State<AutomaticInitializationContent> createState() =>
      _AutomaticInitializationContentState();
}

class _AutomaticInitializationContentState
    extends State<AutomaticInitializationContent> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: [
          const SizedBox(
            height: 24,
          ),
          R89Tag(
            tag: 'banner_tag',
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text(
                'Single Tag: All-in-One\nAd Management Solution for Publishers',
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: 18,
                  fontWeight: FontWeight.w600,
                  color: Colors.grey[800],
                ),
              ),
            ),
          ),
          const Divider(),
          ListTile(
            leading: const Icon(
              Icons.arrow_circle_right_outlined,
              color: Colors.amber,
            ),
            title: const Text('INTERSTITIAL ON NAVIGATION'),
            trailing: const Icon(Icons.chevron_right),
            subtitle: const Text('Navigates and displays an interstitial ad.'),
            onTap: () {
              Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => const FeaturesList(),
                  settings: const RouteSettings(name: 'FeaturesList')));
            },
          ),
          R89Tag(
            tag: 'button_tag',
            child: ListTile(
              leading: const Icon(
                Icons.touch_app_outlined,
                color: Colors.amber,
              ),
              title: const Text('INTERSTITIAL ON TAP EVENT'),
              subtitle: const Text(
                  'Displays an interstitial ad, then runs the tap action.'),
              trailing: const Icon(Icons.chevron_right),
              onTap: () {
                showAdSnackBar(context, 'After the interstitial get closed.');
              },
            ),
          ),
          const Divider(),
          const SizedBox(
            height: 8,
          ),
          const R89Tag(tag: 'banner_tag'),
          R89Tag(
            tag: 'outstream_tag',
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text(
                """The Monetize App SDK has been created with a unique purpose: to make app monetization as easy and flexible as web monetization, solving the most common problems App developers and publishers' encounter""",
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: 16,
                  color: Colors.grey[800],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

class FeaturesList extends StatelessWidget {
  const FeaturesList({super.key});

  @override
  Widget build(BuildContext context) => Scaffold(
    body: Column(
      mainAxisAlignment: MainAxisAlignment.end,
      children: [
        Flexible(
          child: ListView.separated(
            itemCount: 100,
            shrinkWrap: true,
            separatorBuilder: (context, index) => const Divider(),
            itemBuilder: (context, index) => R89Tag(
              tag: 'scroll_tag',
              itemIndex: index,
              child: ListTile(
                leading: const Icon(
                  Icons.star_rounded,
                  color: Colors.amber,
                ),
                title: Text(features[index % features.length]),
              ),
            ),
          ),
        ),
        ListTile(
          tileColor: Colors.yellowAccent,
          leading: const Icon(
            Icons.arrow_back_rounded,
            color: Colors.amber,
          ),
          title: const Text('NAVIGATE BACK WITH INTERSTITIAL'),
          subtitle:
          const Text('Navigates back and displays an interstitial ad.'),
          onTap: () {
            Navigator.of(context).pop();
          },
        ),
      ],
    ),
  );
}

const features = [
  "All-In-One Ad Monetization",
  "Performance Dashboard",
  "No More App "
      "Updates Required",
  "Fully GDPR Compliant CMP"
];

void showAdSnackBar(BuildContext context, String message) {
  ScaffoldMessenger.of(context).showSnackBar(SnackBar(
    content: Text(message),
    duration: const Duration(seconds: 1),
  ));
}
1
likes
130
points
802
downloads

Documentation

API reference

Publisher

verified publisherrefinery89.com

Weekly Downloads

The flutter plugin for the Refinery 89 Monetize App, supporting banner, outStream, interstitial (full-screen) and scrollable ads

Homepage
Repository

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on refinery89_monetize_app

Packages that implement refinery89_monetize_app