pam_flutter 2.4.11 copy "pam_flutter: ^2.4.11" to clipboard
pam_flutter: ^2.4.11 copied to clipboard

A Flutter plugin for integrating mobile Flutter app with PAM Real CDP. learn more about pam at https://pams.ai

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:pam_flutter/pam.dart';
import './pam_config.dart';

void main() {
  var pamConfig = PamConfigProvider.getConfig();
  Pam.initialize(pamConfig);

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    // Display App Attention if exist

    Pam.appAttention(
      context,
      pageName: "home-video",
      onBannerClick: (bannerData) {
        debugPrint("CLICK LEARN MORE.");
        debugPrint(bannerData.toString());
        return false;
      },
    );

    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  void allowConsent() async {
    var trackingConsentMessageID =
        Pam.shared.config?.trackingConsentMessageID ?? "";

    var trackingConsent =
        await Pam.loadConsentMessage(trackingConsentMessageID);
    trackingConsent?.allowAll();

    if (trackingConsent != null) {
      await Pam.submitConsent(trackingConsent);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextButton(
              style: ButtonStyle(
                foregroundColor: WidgetStateProperty.all<Color>(Colors.blue),
              ),
              onPressed: () {
                Pam.allowConsent("2VNmHzWrxPYJj0zDiM1cQGeW2S5");
              },
              child: Text('Allow Consent'),
            ),
            TextButton(
              style: ButtonStyle(
                foregroundColor: WidgetStateProperty.all<Color>(Colors.blue),
              ),
              onPressed: () {
                Pam.appAttention(context, pageName: "home");
              },
              child: Text('Attention'),
            )
          ],
        ),
      ),
    );
  }
}
1
likes
150
points
897
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for integrating mobile Flutter app with PAM Real CDP. learn more about pam at https://pams.ai

Homepage
Repository (GitHub)

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

android_id, device_info_plus, firebase_messaging, flutter, http, package_info_plus, plugin_platform_interface, queue, shared_preferences, url_launcher, uuid

More

Packages that depend on pam_flutter