A mobile puzzle game built with Flutter demonstrating Google AdMob monetization strategies including Banner, Interstitial, Rewarded, Native and App Open ads.
This project focuses on SDK integration, ad lifecycle management, and mobile game UI development.
| Intro Page | Select Level | Gameplay |
|---|---|---|
![]() |
![]() |
. |
| Help | Ad Demo | Finished |
|---|---|---|
![]() |
![]() |
. |
- ๐ฏ 5 Difficulty Levels: From easy (20 turns) to super hard (12 turns)
- ๐จ Modern UI/UX: Gradient backgrounds, animations, and responsive design
- ๐ฐ 5 Types of AdMob Ads: Banner, Interstitial, Rewarded, App Open, Native
- ๐ Help System: Check the rewarded ad to flip a pair of cards.
- ๐ Level Selection: Level selection screen with native ads
- ๐ Smart Ad Management: Cooldown logic to avoid spam ads
- Framework: Flutter 3.x
- Language: Dart
- Ads SDK:
google_mobile_ads: ^5.0.0 - State Management: setState (simple, sufficient)
- Platform: Android & iOS
- Total Lines: ~1,500 lines
- Files: 15 Dart files
- Ad Managers: 5 classes
- Pages: 3 screens
- Widgets: Modular & reusable
- Constants: Centralized configuration
| Ad Type | Location | Usage Strategy | eCPM Potential |
|---|---|---|---|
| Banner Ad | Top & Bottom cแปงa HomePage | โข Always visible during gameplay โข Non-intrusive passive income |
Low |
| Interstitial Ad | Between levels & replay | โข When moving to the next level โข When selecting "Play again" |
High |
| Rewarded Ad | Help feature | โข Opt-in: Active user viewing โข Reward: Automatically flips a pair of cards โข Not counted towards the number of turns |
Very High |
| App Open Ad | App resume (foreground) | โข When the app returns from the background: โข Has a 4-hour cooldown โข Does not show after rewarded/interstitial | Medium |
| Native Ad | Level Selection Page | โข Blends into the natural UI. โข Size: 120px height โข Non-disruptive |
Medium |
IntroPage (Welcome screen)
โ
LevelSelectionPage
โข Native Ad (120px, middle of the screen)
โ (Chแปn level 1-5)
HomePage (Game chรญnh)
โข Banner Ad (Top)
โข Banner Ad (Bottom)
โข Help Button โ Rewarded Ad
โ (Win/Lose)
Game Over Screen
โข "Next screen" โ Interstitial Ad
โข "Replay" โ Interstitial Ad
Background โ Foreground
โข App Open Ad (if no ads have just appeared)
- Rewarded Interstitial Ad: It's not necessary because we already have Interstitial + Rewarded.
๐lib/
โโโ main.dart
โโโ๐models/
โ โโโ card_item.dart
โโโ๐pages/
โ โโโ intro_page.dart
โ โโโ level_selection_page.dart
โ โโโ home_page.dart
โโโ๐services/
โ โโโ app_open_ad_manager.dart
โ โโโ banner_ad_manager.dart
โ โโโ interstital_ad_manager.dart
โ โโโ reward_ad_manager.dart
โ โโโ native_ad_manager.dart
โโโ๐utils/
โ โโโ constants.dart
โโโ๐widgets/
โโโ banner_ad_widget.dart
- PROJECT_STRUCTURE.md: Detailed architecture
- CLEANUP_SUMMARY.md: Refactoring history
- TROUBLESHOOTING.md: Common issues
flutter --version # Flutter >=3.0.0- Clone the repository
git clone <your-repo-url>
cd demo_admobs- Install dependencies
flutter pub get- Configure AdMob
For Testing (Current Setup):
- Using Google's test Ad Unit IDs
- No configuration needed
For Production:
- Update Ad Unit IDs in
lib/utils/constants.dart - Replace test IDs with your real AdMob IDs:
static String get bannerAdUnitId => Platform.isAndroid ? 'ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX' // Your Android ID : 'ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX'; // Your iOS ID
- Run the app
flutter rundependencies {
implementation 'com.google.android.gms:play-services-ads:XX.X.X'
}platform :ios, '12.0'
# AdMob pods auto-added via pubspec.yaml- Launch App โ See Intro Page
- Tap "Chฦกi ngay" โ Level Selection Page
- Choose Level (1-5) โ Tap selected level card
- Tap "Chฦกi Cแบฅp ฤแป X" โ Start game
- Flip Cards โ Find matching pairs
- Use Help (Optional) โ Watch rewarded ad โ Auto-flip 1 pair
- Win โ Next level or replay
- Lose โ Try again
| Level | Max Moves | Difficulty | Color |
|---|---|---|---|
| 1 | 22 | Easy | ๐ข Green |
| 2 | 20 | Medium | ๐ต Blue |
| 3 | 18 | Hard | ๐ Orange |
| 4 | 16 | Very Hard | ๐ด Red |
| 5 | 12 | Extreme | ๐ฃ Purple |
- Passive Income: Banner ads always visible
- High eCPM Points: Interstitial at natural breaks
- User Value: Rewarded ads offer real benefit (help)
- Re-engagement: App Open ads for returning users
- Native Blend: Less intrusive, better CTR
โ
No ad spam: Cooldown logic, strategic placement
โ
User choice: Rewarded ads are opt-in
โ
Natural breaks: Interstitials between levels
โ
Proper disposal: All ads disposed correctly
โ
Error handling: Fallbacks when ads fail to load
โ
Test IDs: Safe for development
This project is for educational purposes. AdMob integration follows Google's policies.
PHแบ M NGแปC MINH
Made with โค๏ธ using Flutter






