Flutter插件rubi_lapisekyc的使用方法

Flutter插件rubi_lapisekyc的使用方法

在本指南中,我们将详细介绍如何使用rubi_lapisekyc插件,并展示其潜在用途。该插件主要用于身份证件验证,可以用于各种场景,例如在线身份验证、用户注册等。

准备资源

首先,你需要将插件资源文件复制到你的项目中。

Copy the assets folder inside the flutter package to your app root folder

Copy env.production and .env.example from the flutter package to your app root folder

Create .env file with the content of env.example in your root folder

Add the above assets to your pubspec.yaml

添加rubi_lapisekyc插件

你可以通过两种方法添加插件:

方法1:从文件系统添加插件

Clone the package or place the package folder in the desired location
Add the package to your pubspec.yaml under dependencies as shown below (the below path is if the package and your app are at the same level of folder structure, replaced with the path of your package location). Change the path to the folder name and location you placed the package

方法2:使用已发布的包

If you are using vs code add rubi_lapisekyc: ^0.0.4 under dependencies in side your pubspec.yaml file and save the file vs code with automatically download the package for you

或者,在项目目录下运行以下命令来添加插件:

Inside your project run the following command to add the package 
flutter pub add rubi_lapisekyc

常规配置

确保你的应用满足最低SDK版本的要求,并添加互联网权限。

Go to android/app/build.gradle and add minSdkVersion 21
and targetSdkVersion 33 under defaultConfig as shown below.

Next add internet permission. Navigate to android/src/main/AndroidManifest.xml and add internet access permission <uses-permission android:name="android.permission.INTERNET"/> as shown below.

导入并使用

接下来,导入插件并初始化它。

// 导入插件
import 'package:rubi_lapisekyc/rubi_lapisekyc.dart';

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

class MyApp extends StatelessWidget {
  [@override](/user/override)
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('ID Card Verification')),
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              // 初始化插件
              final lapisKyc = LapisKyc(
                routeContext: context,
                onSuccess: (data) {
                  // 成功后的回调函数
                  print(data);
                },
              );
              // 启动验证流程
              lapisKyc.startVerification();
            },
            child: Text('Start Verification'),
          ),
        ),
      ),
    );
  }
}

更多关于Flutter插件rubi_lapisekyc的使用方法的实战教程也可以访问 https://www.itying.com/category-92-b0.html

回到顶部