flutter_pipwave_ekyc 0.0.2 copy "flutter_pipwave_ekyc: ^0.0.2" to clipboard
flutter_pipwave_ekyc: ^0.0.2 copied to clipboard

Flutter Packages for Pipwave EKYC

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_pipwave_ekyc/flutter_pipwave_ekyc.dart';
import 'package:flutter_pipwave_ekyc/index.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Pipwave EKYC Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  late TextEditingController accessTokenController;
  late TextEditingController sessionIdController;

  @override
  void initState() {
    super.initState();
    accessTokenController = TextEditingController(text: const String.fromEnvironment('accessToken'));
    sessionIdController = TextEditingController(text: const String.fromEnvironment('sessionId'));
  }

  @override
  void dispose() {
    super.dispose();
    accessTokenController.clear();
    sessionIdController.clear();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextFormField(
              controller: accessTokenController,
              enableSuggestions: false,
              autocorrect: false,
              maxLines: 12,
              decoration: const InputDecoration(
                border: InputBorder.none,
                labelText: 'Access Token',
              ),
            ),
            TextFormField(
              controller: sessionIdController,
              enableSuggestions: false,
              autocorrect: false,
              maxLines: 2,
              decoration: const InputDecoration(
                border: InputBorder.none,
                labelText: 'Session ID',
              ),
            ),
            MaterialButton(
              color: Theme.of(context).colorScheme.primaryContainer,
              onPressed: () {
                FlutterPipwaveEkyc.instance.initializeEkycSession(context,
                accessToken: accessTokenController.text,
                sessionId: sessionIdController.text,
                );
              },
              child: const Text(
                'Start Ekyc Process',
                style: TextStyle(fontSize: 20),
              ),
            ),
          ],
        ),
      ),
    );
  }
}