Flutter plugin to get GAID android and IDFA ios.

Demonstrates how to use the flutter_advertising_id plugin.


To use this plugin, add flutter_advertising_id as a dependency in your pubspec.yaml file.

Getting Started

Check out the example directory for a sample app using flutter advertising id.

In your flutter project add the dependency:

  flutter_advertising_id: ^1.0.3

For help getting started with Flutter, view the online documentation.

Usage example

import package:flutter_advertising_id/flutter_advertising_id.dart;

import 'package:flutter_advertising_id/flutter_advertising_id.dart';
class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  String _advertisingId = 'Unknown';

  void initState() {

  // AdvertisingId are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String advertisingId;
    // Advertising id may fail, so we use a try/catch PlatformException.
    try {
      advertisingId = await FlutterAdvertisingId.advertisingId;
    } on PlatformException {
      advertisingId = 'Failed to get platform version.';

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _advertisingId = advertisingId;

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        body: Center(
          child: Text('Running on: $_advertisingId\n'),