flutter_aadhaar_xml_sdk

pub package

A Flutter plugin to get details from aadhaar xml on Android and iOS

. Supports iOS, Android.

Usage

To use this plugin, add flutter_aadhaar_xml_sdk as a dependency in your pubspec.yaml file.

Installation

Android

Add following in AndroidManifest.xml

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Add following in build.gradle

        minSdkVersion 18
        targetSdkVersion 29

Add following in styles.xml

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <!-- Theme applied to the Android Window while the process is starting -->
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <!-- Theme applied to the Android Window as soon as the process has started.
         This theme determines the color of the Android Window while your
         Flutter UI initializes, as well as behind your Flutter UI while its
         running.
         
         This Theme is only used starting with V2 of Flutter's Android embedding. -->
    <style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="android:windowBackground">@android:color/white</item>
    </style>
</resources>

Replace activity theme with following

android:theme="@style/LaunchTheme"

iOS

Add following in Podfile

source 'https://github.com/CocoaPods/Specs.git'

source 'https://bitbucket.org/ios-external/podspecs.git'

target '${OfflineKYCExample}' do

  use_frameworks!

  pod 'OfflineAadhaar'

end

Add following in Info.plist.

	<key>UIViewControllerBasedStatusBarAppearance</key>
	<true/>
	<key>UIStatusBarStyle</key>
	<string>UIStatusBarStyleDarkContent</string>

Example

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

import 'package:flutter/services.dart';
import 'dart:io';
import 'package:flutter_aadhaar_xml_sdk/AndroidAadhaarModel.dart';
import 'package:flutter_aadhaar_xml_sdk/IosAadhaarModel.dart';
import 'package:flutter_aadhaar_xml_sdk/flutter_aadhaar_xml_sdk.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _xmlData = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    // HashMap map1 = new HashMap<dynamic, dynamic>();

    // String platformVersion;
    // Object deviceObject;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      String token =
          "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXF1ZXN0X2lkIjoiZmJkODhmYTgtMzI5ZS00NGU3LWE1NmItOGJhYzQ0ZTAwYzA1IiwidXNlcl9pZCI6MzkwNzUwLCJzY29wZSI6WyJhYWRoYWFyX3htbCIsInZpZGVvX2t5YyIsImxpdmVuZXNzIl0sImVudiI6InRlc3QiLCJjbGllbnRfaWQiOiJSYWluX0luY19iTTVCNXMiLCJzdGFnZSI6InRlc3QiLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImV4cGlyeV90aW1lIjoiMjctMDgtMjAyMVQxMDo1NDo0OCIsInRyYW5zYWN0aW9uSWQiOiIwMWIwMzE2NjA3MjExMWVjODk5MDdlZDU1OGRmNmJlOSJ9.UI0tti-zft-bxSjaYjvQDtHw2BLt02zOZUDzk2vxXc0";
      String env = "test";
      String client = "";
      AndroidAadhaarModel androidMap;
      String finalVal = "";
      IosAadhaarModel iosMap;
      if (Platform.isAndroid) {
        androidMap = await FlutterAadhaarXmlSdk.startSdk(token, env, client);
        String name = androidMap.name;
        String dob = androidMap.dob;
        print("name is ${name} and dob is ${dob}");
        finalVal = "name is ${name} and dob is ${dob}";
      } else if (Platform.isIOS) {
        iosMap = await FlutterAadhaarXmlSdk.startSdk(token, env, client);
        String name = iosMap.name;
        String dob = iosMap.dob;
        print("name is ${name} and dob is ${dob}");
        finalVal = "name is ${name} and dob is ${dob}";
      }

      setState(() {
        _xmlData = finalVal;
      });
      // return map1;
    } on PlatformException {
      // platformVersion = 'Failed to get platform version.';

      // If the widget was removed from the tree while the asynchronous platform
      // message was in flight, we want to discard the reply rather than calling
      // setState to update our non-existent appearance.
      if (!mounted) return;
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('$_xmlData\n'),
        ),
      ),
    );
  }
}

enum EnumEnv { prod, beta, test }

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Libraries

AndroidAadhaarModel
flutter_aadhaar_xml_sdk
IosAadhaarModel