Adsbravo Flutter
AdsbravoFlutter is a Flutter library that allows you to easily integrate advertising into your apps using the Adsbravo platform.
It enables you to display banners, collapsible banners, interstitials, rewardeds, and open app ads with a simple API.
🚀 Features
- ✅ Simple initialization with
tokenandsecret - ✅ Load and display Interstitial Ads
- ✅ Load and display Rewarded Ads (with reward listener)
- ✅ Fixed banner (
BannerWidget) - ✅ Collapsible banner (
CollapsibleBannerWidget)
📦 Installation
Add the dependency in your pubspec.yaml:
dependencies:
adsbravo_flutter: ^1.0.0 # or the version you publish
Then run:
flutter pub get
🎬 Basic Usage
1️⃣ Initialization
Before showing ads, you must initialize Adsbravo:
import 'package:adsbravo_flutter/adsbravo_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await AdsbravoFlutter.init(
token: '7QmVdSGyOWPg7quoG6oft0',
secret: '280f0841cb285bf2d8116756490e280adb167a54f93e3abf7c5f42faa521b97e',
);
runApp(MyApp());
}
2️⃣ Displaying a banner
import 'package:adsbravo_flutter/adsbravo_flutter.dart';
@override
Widget build(BuildContext context) {
return const BannerWidget();
}
3️⃣ Displaying a collapsible banner
import 'package:adsbravo_flutter/adsbravo_flutter.dart';
@override
Widget build(BuildContext context) {
return const CollapsibleBannerWidget();
}
4️⃣ Interstitial Ads
Load and display:
To display interstitial ads in different parts of the app, you should use different sourceId values for each location (e.g., "home_screen").
const String sourceId = 'YOUR_SOURCE_ID';
await AdsbravoFlutter.loadInterstitial(sourceId);
// When you want to display it:
await AdsbravoFlutter.showInterstitial(sourceId);
⚠️ Important:
If an interstitial ad has already been loaded with a specificsourceId, another one with the samesourceIdwill not be loaded again.
However, you can reuse the samesourceIdfor different ad types, such as rewarded ads.
This means thesourceIdmust be unique per ad type, but not necessarily unique across all ad types.
5️⃣ Rewarded Ads
Load, display, and listen for rewards:
To display rewarded ads in different parts of the app, you should use different sourceId values for each location (e.g., "home_screen").
const String sourceId = 'YOUR_SOURCE_ID';
// Set the listener:
AdsbravoFlutter.setRewardListener(() {
print('User received the reward!');
});
// Load the ad:
await AdsbravoFlutter.loadRewarded(sourceId);
// When you want to display it:
await AdsbravoFlutter.showRewarded(sourceId);
⚠️ Important: Same as interstitial explanation above.
6️⃣ Open App Ads (if you use this functionality):
(These show when the app is minimized and reopened)
await AdsbravoFlutter.initOpenApp();
⚠️ Compatibility
- ✅ Android supported
- ⚠️ iOS: currently
BannerWidgetandCollapsibleBannerWidgetare not supported on iOS (a placeholder text is shown).
📋 Notes
-
The library exposes the following components:
AdsbravoFlutter: main class for initialization and controlling interstitial/rewarded/open app ads.BannerWidget: widget to display a fixed banner.CollapsibleBannerWidget: widget to display a collapsible banner with automatic animation.
📝 License
This project is licensed under the MIT license. See the LICENSE file for details.