iabtcf_consent_info_web 1.2.0 iabtcf_consent_info_web: ^1.2.0 copied to clipboard
Web implementation of the iabtcf_consent_info plugin.
// ignore_for_file: public_member_api_docs
import 'package:flutter/material.dart';
import 'package:iabtcf_consent_info/iabtcf_consent_info.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'IABTCF Consent Info Example',
home: IabtcfConsentInfoViewer(),
);
}
}
class IabtcfConsentInfoViewer extends StatefulWidget {
@override
_IabtcfConsentInfoViewerState createState() =>
_IabtcfConsentInfoViewerState();
}
class _IabtcfConsentInfoViewerState extends State<IabtcfConsentInfoViewer> {
late Stream<ConsentInfo?> consentInfoStream;
@override
void initState() {
consentInfoStream = IabtcfConsentInfo.instance.consentInfo();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('IABTCF Consent Info Example'),
),
body: StreamBuilder<ConsentInfo?>(
stream: consentInfoStream,
builder: (context, snapshot) => Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
snapshot.hasData
? snapshot.data.toString()
: snapshot.hasError
? snapshot.error.toString()
: 'Loading...',
),
),
),
),
);
}
}