Flutter GDPR Admob Package

This guide provides a basic understanding of how to use the gdpr_admob package in a Flutter application.


The gdpr_admob package helps you display a GDPR consent form to users within the European Economic Area (EEA) and initialize Google Mobile Ads based on user consent. This guide explains how to set it up in your Flutter app.

First release of gdpr_admob package

Step-by-Step Guide

1. Add Dependencies

Add the following dependencies to your pubspec.yaml file:

    sdk: flutter
  google_mobile_ads: ^5.1.0
  gdpr_admob: ^1.0.1

2. Import Packages

Import the required packages in your Dart file:

import 'package:flutter/material.dart';
import 'package:gdpr_admob/gdpr_admob.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';

3. Initializing GDPR

In your Stateful widget, create an instance of GdprAdmob and define a method to initialize it. This method will set the GDPR consent status for the user.

final GdprAdmob gdprAdmob = GdprAdmob();
bool _isLoading = false;
String? _errorMessage;
String? _consentStatus;

Future<void> _initializeGdpr() async {
  setState(() {
    _isLoading = true;

  final error = await gdprAdmob.initialize(
    mode: DebugGeography.debugGeographyEea,

  if (error != null) {
    setState(() {
      _errorMessage = error.message;

  setState(() {
    _isLoading = false;

Define another method to get the current consent status of the user.

getStatus() async {
  final status = await gdprAdmob.getConsentStatus();
  setState(() {
    _consentStatus = status;

5. Displaying GDPR Dialog

You can now use these methods in your widget tree to display the GDPR dialog and get the consent status. You can also reset the consent status using the resetConsentStatus method.

  onPressed: _initializeGdpr,
  child: const Text("Show GDPR dialog"),
  onPressed: () async {
    await gdprAdmob.resetConsentStatus();
  child: const Text("Reset the consent state"),
if (_consentStatus != null)
  Text('Consent Status: $_consentStatus'),
if (_errorMessage != null) Text('Error: $_errorMessage'),

That's it! You have now integrated the gdpr_admob package into your Flutter application.