flutter_consent_flow 1.0.3 copy "flutter_consent_flow: ^1.0.3" to clipboard
flutter_consent_flow: ^1.0.3 copied to clipboard

PlatformAndroidiOS
outdated

This library provides methods to identify the relevant regulatory framework based on the user's IP or location and request consent from the user.

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'),
                ),
              )
            ],
          ),
        );
      }),
    );
  }
}
3
likes
150
points
18
downloads

Publisher

verified publisherinfoowly.com

Weekly Downloads

This library provides methods to identify the relevant regulatory framework based on the user's IP or location and request consent from the user.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, geocoding, geolocator, http, url_launcher

More

Packages that depend on flutter_consent_flow