smart_ads_manager 0.0.5+4
smart_ads_manager: ^0.0.5+4 copied to clipboard
A Flutter ads management package that provides banner, interstitial, native, and app open ads with Firebase Remote Config support for centralized ad control across multiple apps.
Smart Ads Manager #
A reusable Flutter package for managing Google Mobile Ads across Android and iOS from a centralized API.
smart_ads_manager supports Banner, Interstitial, Native, and App Open Ads, with centralized configuration, optional Firebase Remote Config support, ad preloading, and subscription-aware ad handling.
Features #
- ✅ Banner Ads
- ✅ Interstitial Ads
- ✅ Native Ads
- ✅ App Open Ads
- ✅ Ad Preloading
- ✅ GMA Next-Gen SDK support
- ✅ Firebase Remote Config integration
- ✅ Enable/disable ads remotely
- ✅ Centralized ad configuration
- ✅ Platform-specific AdMob IDs
- ✅ Reusable ad managers
- ✅ Prevents duplicate ad loading
- ✅ Subscription/Remove Ads support
- ✅ Easy initialization
- ✅ Android and iOS support
- ✅ Production-ready architecture
Requirements #
- Flutter 3.x or later
- Android and iOS
- Google AdMob account
- Firebase project (only required if using Remote Config)
Installation #
Add smart_ads_manager to your pubspec.yaml:
dependencies:
smart_ads_manager: ^0.0.4
Then run:
flutter pub get
Replace
^0.0.2with the latest version available on pub.dev.
Initialization #
Initialize the package when your application starts:
await AdsInitializer.init(
config: AdsConfig(
bannerId: 'YOUR_BANNER_AD_UNIT_ID',
interstitialId: 'YOUR_INTERSTITIAL_AD_UNIT_ID',
nativeId: 'YOUR_NATIVE_AD_UNIT_ID',
appOpenId: 'YOUR_APP_OPEN_AD_UNIT_ID',
),
);
Make sure initialization happens before displaying ads.
Banner Ads #
Load the banner once:
SmartBannerAdManager.load();
Then display the banner wherever required:
SmartBannerAdWidget();
The manager handles the ad lifecycle so the same loaded ad can be reused where supported by the package architecture.
You can also provide custom configuration such as padding, expandable behavior, and loading UI.
Interstitial Ads #
Show an interstitial ad:
SmartDirectAdManager.show(
onClosed: () {
// Continue navigation or application flow
},
);
The package handles ad availability and lifecycle callbacks.
Native Ads #
Display a native ad using:
SmartNativeAdWidget();
You can customize the native ad appearance according to your application's design.
App Open Ads #
App Open Ads can be loaded and displayed through the package's centralized App Open Ad manager.
The manager handles:
- Loading
- Availability
- Showing
- Dismissal
- Ad lifecycle
This makes App Open Ads easier to integrate without duplicating implementation across your application.
Ad Preloading #
Ads can be preloaded before they are needed.
For example:
SmartBannerAdManager.load();
Preloading helps reduce the delay between requesting an ad and displaying it to the user.
The same centralized approach can be used for supported interstitial and App Open ad flows.
Firebase Remote Config #
The package optionally supports Firebase Remote Config.
You can use Remote Config to control ad behavior without releasing a new application version.
For example, you can remotely control:
- Ads enabled/disabled
- Banner enabled/disabled
- Interstitial enabled/disabled
- Native enabled/disabled
- App Open enabled/disabled
- Interstitial frequency
This allows you to change advertising behavior remotely.
Platform Ad IDs #
Android and iOS can use different AdMob ad unit IDs.
Configure platform-specific IDs according to your application:
PlatformAdIds(
android: ...,
ios: ...,
);
This keeps platform-specific configuration centralized and prevents ad IDs from being duplicated throughout the application.
Remove Ads / Subscription #
If your application provides a premium subscription or one-time Remove Ads purchase, the package can be integrated with your subscription state.
When the user has premium access, ads can be skipped automatically.
Example:
AppAdHelper.banner();
The helper can return an empty widget when ads should not be displayed, preventing unnecessary layout space from being reserved.
Recommended Architecture #
A typical integration can look like:
Application
│
├── AdsInitializer
│
├── AdsConfig
│
├── PlatformAdIds
│
├── SmartBannerAdManager
│
├── SmartDirectAdManager
│
├── Native Ads
│
└── App Open Ads
This keeps advertising logic separate from individual screens and makes the package reusable across multiple Flutter applications.
Example #
A basic application setup:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await AdsInitializer.init(
config: AdsConfig(
bannerId: 'YOUR_BANNER_ID',
interstitialId: 'YOUR_INTERSTITIAL_ID',
nativeId: 'YOUR_NATIVE_ID',
appOpenId: 'YOUR_APP_OPEN_ID',
),
);
runApp(const MyApp());
}
Then on a screen:
Column(
children: [
const Expanded(
child: YourPageContent(),
),
AppAdHelper.banner(),
],
)
Testing #
Use Google's test ad unit IDs during development.
Do not use production ad unit IDs while testing your application.
Publishing / Updating #
To publish a new version of smart_ads_manager:
flutter pub get
flutter analyze
flutter test
dart pub publish --dry-run
dart pub publish
Before publishing, update the package version in pubspec.yaml and document changes in CHANGELOG.md.
Changelog #
See CHANGELOG.md for version history and release notes.
License #
This package is released under the MIT License.