piano_consents 1.0.0
piano_consents: ^1.0.0 copied to clipboard
Piano Consents SDK for Flutter
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:piano_consents/piano_consents.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _pianoConsents = PianoConsents(
requireConsents: true,
defaultPurposes: {
PianoConsentProduct.pa: PianoConsentPurpose.audienceMeasurement
}
);
@override
void initState() {
super.initState();
initPlugins();
}
Future<void> initPlugins() async {
await _pianoConsents.init();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Piano consents'),
),
body: Center(
child: Column(
children: [
FilledButton(
onPressed: () async {
await _pianoConsents.set(
purpose: PianoConsentPurpose.audienceMeasurement,
mode: PianoConsentMode.optIn,
products: [PianoConsentProduct.pa]);
},
child: const Text("Set consents")),
FilledButton(
onPressed: () async {
await _pianoConsents.setAll(mode: PianoConsentMode.optOut);
},
child: const Text("Set all consents")),
FilledButton(
onPressed: () async {
await _pianoConsents.clear();
},
child: const Text("Clear consents"))
],
),
),
),
);
}
}