Flutter

This is a walkthrough of how you can itegrate the Oboarding or Authenticate SDK for Flutter applications.

Getting started

In order to perform an Onboarding or an Authenticate, you should follow those steps:

1. Integrate the SDK

The Flutter SDK supports:

  • Dart 3.0.0 or higher

  • Flutter 3.0.0 or higher

  • Android API level 24+

  • Kotlin 1.8.0 or higher

  • IOS 15.0 or higher

  • Targeted Device Families = iPhone, iPad

Mandatory app permision for iOS

The SDK uses the device's camera functionality.

You must add NSCameraUsageDescription within your application's Info.plist file (see Apple documentation).

Installing SDK

Run this command with Flutter:

 $ flutter pub add shareid_sdk_flutter

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  shareid_sdk_flutter: ^2.0.1

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Then import the SDK, in your Dart code, you can use:

import 'package:shareid_sdk_flutter/shareid_sdk_flutter.dart'

2. Get a token

Use the credentials you received from ShareID's team to get an authenticate token and launch an onboarding or authenticate workflow.

Depending on the SDK you are integrating (Onboarding/Authenticate), you may use an API here Get a Token

3. Start an onboarding or authenticate flow

Use your token to start an onboarding or an authenticate, you can configure the SDK :

final _shareid = ShareidOnboarding();

_shareid.onboarding("SHARE_ID_SERVER_URL","SHARE_ID_SERVICE_TOKEN").then((value) {
    setState(() {
      Map<String, dynamic> valueMap = json.decode(value!);
      result = MessageHandler.fromJson(valueMap);
      switch (result.messageHandler) {
          case "success":
            Fluttertoast.showToast(msg: result.message!);
            break;
          case "exit":
            Fluttertoast.showToast(msg: result.message!);
            break;
          case "failure":
            Fluttertoast.showToast(msg: result.message!);
            break;
          default:
            break;
        }
    });
});

For more informations : Example File

For authenticate:

final _shareid = ShareidAuthenticate();

_shareid.authenticate("SHARE_ID_SERVER_URL","SHARE_ID_SERVICE_TOKEN").then((value) {
    setState(() {
      Map<String, dynamic> valueMap = json.decode(value!);
      result = MessageHandler.fromJson(valueMap);
      switch (result.messageHandler) {
          case "success":
            Fluttertoast.showToast(msg: result.message!);
            break;
          case "exit":
            Fluttertoast.showToast(msg: result.message!);
            break;
          case "failure":
            Fluttertoast.showToast(msg: result.message!);
            break;
          default:
            break;
        }
    });
});

For more informations : Example File

The table below describes the list of parameters:

4. Get the user workflow result from SDK (Message Handling)

In order to retrieve ShareID results from the flow, you can json.decode the result and use the class MessageHandler to retrieve the different result.

5. Get the Analysis result

When the processing of an onboarding request is finished, you may receive the result through the callback if you provided it. You may also, fetch yourself the result by calling our API.

See Fetch result for more details.

Last updated