flutter_consent_flow 1.0.1
flutter_consent_flow: ^1.0.1 copied to clipboard
A Flutter utility library for handling regulatory frameworks and geolocation permissions. This library provides methods to identify the relevant regulatory framework based on the user's IP or location [...]
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_consent_flow/flutter_consent_flow.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Consent Flow',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: Builder(builder: (context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: FilledButton(
onPressed: () async {
final RegulatoryFramework? regulatoryFramework =
await FlutterConsentFlow.getRegulatoryFrameworkByIP(
apiKey: 'YOUR_API_KEY',
);
if (regulatoryFramework == null) return;
if (context.mounted) {
/// handle consent
final bool? hasConsent = await showDialog(
context: context,
builder: (_) => FlutterConsentDialog(
regulatoryFramework: regulatoryFramework,
appIcon: const AssetImage('YOUR_APP_ICON'),
appName: 'YOUR_APP_NAME',
privacyPolicyLink: 'YOUR_PRIVACY_POLICY_URL',
),
);
if (hasConsent ?? false) {
/// user has given consent
} else {
/// user
}
}
},
child: const Text('Check & Request'),
),
)
],
),
);
}),
);
}
}