google_ads_deferred_deep_link 1.0.1 copy "google_ads_deferred_deep_link: ^1.0.1" to clipboard
google_ads_deferred_deep_link: ^1.0.1 copied to clipboard

PlatformAndroid

Flutter Plugin for Google Ads Deferred Deep Link. Your app users can now be navigated to an appropriate page when they first download and open your app from Google Ads.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_ads_deferred_deep_link/google_ads_deferred_deep_link.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _deepLink = 'Unknown';
  final _googleAdsDeferredDeepLinkPlugin = GoogleAdsDeferredDeepLink();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> _fetchDeferredDeepLink() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      _googleAdsDeferredDeepLinkPlugin.deferredDeepLinkStream.listen((event) {
        if (mounted) {
          setState(() {
            _deepLink = event?.deepLink ?? 'Callback Error';
          });
        }
      });
      _googleAdsDeferredDeepLinkPlugin.startFetch();
    } on PlatformException {
      if (mounted) {
        setState(() {
          _deepLink = 'Start Error';
        });
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Fetched deep link: $_deepLink\n'),
        ),
      ),
    );
  }
}
2
likes
150
points
423
downloads

Publisher

verified publisherweicongcong.com

Weekly Downloads

Flutter Plugin for Google Ads Deferred Deep Link. Your app users can now be navigated to an appropriate page when they first download and open your app from Google Ads.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on google_ads_deferred_deep_link