How abdullah-youssef/gdpr_admob works
Project Type and Purpose
• This is a Flutter “plugin” package named gdpr_admob. Its job is to present a GDPR consent form to EEA users and then initialize Google Mobile Ads in a Flutter app according to the user’s choice.
• The top‐level lib/ folder contains the Dart API, and the example/ folder holds a full multi‐platform Flutter application demonstrating usage on Android, iOS, Linux, macOS, Windows, and Web.
File Structure
• Top‐level: plugin config files (pubspec.yaml, .gitignore, LICENSE, etc.) plus lib/, test/, example/.
• lib/gdpr_admob.dart and lib/src/gdpr_admob.dart: Dart wrapper that exposes GdprAdmob class with methods like initialize(), getConsentStatus(), resetConsentStatus().
• example/: a standard Flutter app scaffold, with platform directories under android/, ios/, linux/, macos/, windows/, web/ linking in the plugin and demonstrating UI interactions.
• No custom native source in the plugin root—platform code is pulled in via MethodChannels to the Google Mobile Ads SDK / UMP libraries provided by each platform.
Main Components
a. Flutter Application (UI Layer)
• Widgets invoking GdprAdmob.initialize(), listening for results, showing dialogs or messages.
b. Plugin API Layer (Dart)
• GdprAdmob singleton class in lib/, exposing Futures and callbacks to the app.
c. Platform Channel Bridge
• One or more MethodChannel instances behind the scenes, routing Dart calls to native code on each platform.
d. Native Platform Modules
• Google’s User Messaging Platform (UMP)/Consent SDK + Google Mobile Ads SDK on Android, iOS, macOS, Windows, Linux.
e. External Services
• Google Consent Servers (for GDPR rules and form content)
• Google AdMob Ad Servers (for fetching and serving ads post‐consent)
Architectural Patterns and Design Principles
• Plugin Pattern: clean separation between Dart API and native implementations via MethodChannel.
• Singleton + Async Futures: GdprAdmob as a lazily‐initialized singleton exposing async methods.
• Cross‐platform layering: one Dart interface, multiple native backends.
Technologies, Frameworks, and Libraries
• Flutter (Dart)
• MethodChannel (Flutter plugin interop)
• Google Mobile Ads SDK (androidX, iOS CocoaPod, etc.)
• Google User Messaging Platform (Consent SDK)
• pub.dev plugin tooling (pubspec, example project)