flutter_consent_flow 1.0.0
flutter_consent_flow: ^1.0.0 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(
title: 'Flutter Consent Flow',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FilledButton(
onPressed: () async {
final RegulatoryFramework? regulatoryFramework =
await FlutterConsentFlow.getRegulatoryFrameworkByIP(
apiKey: 'YOUR_API_KEY',
ifFailed: () {
debugPrint('UNABLE TO FIND `RegulatoryFramework`');
/// handle if task failed
},
);
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',
),
);
}
},
child: const Text('Check & Request'),
)
],
),
),
);
}
}