Skip to content

Commit

Permalink
upgraded flutter package
Browse files Browse the repository at this point in the history
  • Loading branch information
nooralibutt committed Nov 5, 2023
1 parent 5a5c629 commit fc4bffc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.4.0
* Updates loader argument names and adds assert
* Update `applovin_max: ^3.3.0`
* Update `google_mobile_ads: ^3.1.0`
* Update `unity_ads_plugin: ^0.3.10`

## 2.3.6
* Updates dependencies
* Update `applovin_max: ^3.2.0`
Expand Down
11 changes: 6 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ class _CountryListScreenState extends State<CountryListScreen> {
}

void _showAd(AdNetwork adNetwork, AdUnitType adUnitType) {
if (EasyAds.instance.showAd(adUnitType,
adNetwork: adNetwork,
shouldShowLoader: Platform.isAndroid,
context: context,
delayInSeconds: 1)) {
if (EasyAds.instance.showAd(
adUnitType,
adNetwork: adNetwork,
context: context,
loaderDuration: 1,
)) {
// Canceling the last callback subscribed
_streamSubscription?.cancel();
// Listening to the callback from showRewardedAd()
Expand Down
20 changes: 11 additions & 9 deletions lib/src/easy_ads.dart
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,16 @@ class EasyAds {
///
/// [adUnitType] should be mentioned here, only interstitial or rewarded should be mentioned here
/// if [adNetwork] is provided, only that network's ad would be displayed
/// if [shouldShowLoader] before interstitial. If it's true, you have to provide build context.
/// if [loaderDuration] is > 0 then it will show loader before showing ad, and use [loaderDuration] in seconds. Also, you have to provide build context.
bool showAd(AdUnitType adUnitType,
{AdNetwork adNetwork = AdNetwork.any,
bool shouldShowLoader = false,
int delayInSeconds = 2,
int loaderDuration = 0,
BuildContext? context}) {
if (loaderDuration > 0) {
assert(context != null,
"Loader duration is greater than zero, context has to be provided in order to show dialog");
}

List<EasyAdBase> ads = [];
if (adUnitType == AdUnitType.rewarded) {
ads = _rewardedAds;
Expand All @@ -387,10 +391,9 @@ class EasyAds {
final ad = ads.firstWhereOrNull((e) => adNetwork == e.adNetwork);
if (ad?.isAdLoaded == true) {
if (ad?.adUnitType == AdUnitType.interstitial &&
shouldShowLoader &&
loaderDuration > 0 &&
context != null) {
showLoaderDialog(context, delay: delayInSeconds)
.then((_) => ad?.show());
showLoaderDialog(context, loaderDuration).then((_) => ad?.show());
} else {
ad?.show();
}
Expand All @@ -407,10 +410,9 @@ class EasyAds {
if (ad.isAdLoaded) {
if (adNetwork == AdNetwork.any || adNetwork == ad.adNetwork) {
if (ad.adUnitType == AdUnitType.interstitial &&
shouldShowLoader &&
loaderDuration > 0 &&
context != null) {
showLoaderDialog(context, delay: delayInSeconds)
.then((_) => ad.show());
showLoaderDialog(context, loaderDuration).then((_) => ad.show());
} else {
ad.show();
}
Expand Down
5 changes: 3 additions & 2 deletions lib/src/utils/auto_hiding_loader_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

Future showLoaderDialog(BuildContext context, {int delay = 2}) {
Future showLoaderDialog(BuildContext context, int duration) {
const alert = AlertDialog(
content: Column(
mainAxisSize: MainAxisSize.min,
Expand All @@ -12,7 +12,8 @@ Future showLoaderDialog(BuildContext context, {int delay = 2}) {
),
);

Future.delayed(Duration(seconds: delay), () => Navigator.of(context).pop());
Future.delayed(
Duration(seconds: duration), () => Navigator.of(context).pop());
return showDialog(
barrierDismissible: false,
context: context,
Expand Down
14 changes: 7 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: easy_ads_flutter
description: Easy Ads is a wrapper around famous ad packages which let you integrate ads easily
version: 2.3.6
version: 2.4.0
homepage: https://github.com/nooralibutt/easy-ads
repository: https://github.com/nooralibutt/easy-ads

Expand All @@ -11,14 +11,14 @@ environment:
dependencies:
flutter:
sdk: flutter
google_mobile_ads: ^3.0.0
collection: ^1.17.1
unity_ads_plugin: ^0.3.8
applovin_max: ^3.2.0
google_mobile_ads: ^3.1.0
collection: ^1.17.2
unity_ads_plugin: ^0.3.10
applovin_max: ^3.3.0
easy_audience_network: ^0.0.6
logger: ^2.0.1
logger: ^2.0.2+1

dev_dependencies:
flutter_lints: ^2.0.3
flutter_lints: ^3.0.1

flutter:

0 comments on commit fc4bffc

Please sign in to comment.