flutter_advertising_id 1.0.3 icon indicating copy to clipboard operation
flutter_advertising_id: ^1.0.3 copied to clipboard

Flutter plugin for Android and IOS, a cross-platform to get Advertising id that is GAID for android and IDFA for ios.

flutter_advertising_id #

Flutter plugin to get GAID android and IDFA ios.

Demonstrates how to use the flutter_advertising_id plugin.

Usage #

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:

dependencies:
  ...
  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 {
  @override
  _MyAppState createState() => _MyAppState();
}

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

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // 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;
    });
  }

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

4
likes
100
pub points
66%
popularity

Publisher

unverified uploader

Flutter plugin for Android and IOS, a cross-platform to get Advertising id that is GAID for android and IDFA for ios.

Homepage

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_advertising_id