kycdd 1.2.1 copy "kycdd: ^1.2.1" to clipboard
kycdd: ^1.2.1 copied to clipboard

A package to help kycdd clients integrate with the KYCdd environment.

example/kycdd_example.dart

import 'package:flutter/material.dart';
import 'package:kycdd/kycdd.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  final TextEditingController _apiKeyController = TextEditingController();
  final TextEditingController _workflowIDController = TextEditingController();
  final TextEditingController _customIDController = TextEditingController();
  String? _clientId;
  String? _receivedData;

  @override
  void initState() {
    super.initState();

    Kycdd.dataStream.listen((data) {
      setState(() {
        _receivedData = data;
      });
    });
  }

  void _configure() {
    Kycdd.config(
      apiKey: _apiKeyController.text,
      workflowID: _workflowIDController.text,
    );
  }

  Future<void> _createClient() async {
    try {
      final clientId = await Kycdd.createClient(
        customID: _customIDController.text,
      );
      setState(() {
        _clientId = clientId;
      });

      if (clientId != null) {
        // Navigate to WebView and wait for result
        await Navigator.of(context).push(
          MaterialPageRoute(
            builder: (context) => Kycdd.webView(clientId, context),
          ),
        );
      }
    } catch (e) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text('Failed to create client: $e')),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('My Flutter Package Test App'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            TextField(
              controller: _apiKeyController,
              decoration: InputDecoration(labelText: 'API Key'),
            ),
            TextField(
              controller: _workflowIDController,
              decoration: InputDecoration(labelText: 'Workflow ID'),
            ),
            TextField(
              controller: _customIDController,
              decoration: InputDecoration(labelText: 'Custom ID (optional)'),
            ),
            SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                _configure();
                _createClient();
              },
              child: Text('Configure and Create Client'),
            ),
            if (_receivedData != null) ...[
              SizedBox(height: 20),
              Text('Received Data: $_receivedData'),
            ],
          ],
        ),
      ),
    );
  }
}
0
likes
120
points
40
downloads

Publisher

verified publisherkycdd.co.za

Weekly Downloads

A package to help kycdd clients integrate with the KYCdd environment.

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

file_picker, flutter, flutter_inappwebview, http, permission_handler

More

Packages that depend on kycdd