Skip to content

anhminhvdvn/flutter-admob-puzzle-game-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Memory Card Game with AdMob Integration

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.

๐ŸŽฌ Demo AdMob SDK


๐Ÿ–ผ Screenshots

Intro Page Select Level Gameplay
.
Help Ad Demo Finished
.

โœจ Key Features

  • ๐ŸŽฏ 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

๐Ÿ”ง Tech Stack

  • Framework: Flutter 3.x
  • Language: Dart
  • Ads SDK: google_mobile_ads: ^5.0.0
  • State Management: setState (simple, sufficient)
  • Platform: Android & iOS

Code Metrics

  • Total Lines: ~1,500 lines
  • Files: 15 Dart files
  • Ad Managers: 5 classes
  • Pages: 3 screens
  • Widgets: Modular & reusable
  • Constants: Centralized configuration

๐Ÿ“ฆ AdMob Integration Details

โœ… Implemented Ad Formats (5/6)

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

๐Ÿ“Š Ad Placement Strategy

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)

๐Ÿšซ Not Implemented

  • Rewarded Interstitial Ad: It's not necessary because we already have Interstitial + Rewarded.

๐Ÿ“‚ Project Structure

๐Ÿ“‚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                        

๐Ÿ“š Documentation

๐Ÿš€ Getting Started

Prerequisites

flutter --version  # Flutter >=3.0.0

Installation

  1. Clone the repository
git clone <your-repo-url>
cd demo_admobs
  1. Install dependencies
flutter pub get
  1. 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
  1. Run the app
flutter run

๐Ÿ”ง Configuration Files

Android Setup (android/app/build.gradle)

dependencies {
    implementation 'com.google.android.gms:play-services-ads:XX.X.X'
}

iOS Setup (ios/Podfile)

platform :ios, '12.0'
# AdMob pods auto-added via pubspec.yaml

๐ŸŽฎ How To Play

  1. Launch App โ†’ See Intro Page
  2. Tap "Chฦกi ngay" โ†’ Level Selection Page
  3. Choose Level (1-5) โ†’ Tap selected level card
  4. Tap "Chฦกi Cแบฅp ฤแป™ X" โ†’ Start game
  5. Flip Cards โ†’ Find matching pairs
  6. Use Help (Optional) โ†’ Watch rewarded ad โ†’ Auto-flip 1 pair
  7. Win โ†’ Next level or replay
  8. Lose โ†’ Try again

๐Ÿ† Level Difficulty

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

๐Ÿ’ฐ Monetization Strategy

Revenue Optimization

  1. Passive Income: Banner ads always visible
  2. High eCPM Points: Interstitial at natural breaks
  3. User Value: Rewarded ads offer real benefit (help)
  4. Re-engagement: App Open ads for returning users
  5. Native Blend: Less intrusive, better CTR

Best Practices Implemented

โœ… 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

๐Ÿ“„ License

This project is for educational purposes. AdMob integration follows Google's policies.


๐Ÿ‘ค Author

PHแบ M NGแปŒC MINH


Made with โค๏ธ using Flutter

About

A Flutter memory puzzle game demonstrating Google AdMob monetization with Banner, Interstitial, Rewarded, Native, and App Open ads.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors