Flutter

Add the Mati button to your Flutter app.

Mati for Flutter Usage Guide

Flutter Demo App

You can go to GitHub to download the Mati Flutter demo app.

Dependencies

Add mati_plugin_flutter dependency to your pubspec.yaml file:

  mati_plugin_flutter: 3.3.1

Install Mati for Flutter

Install the Mati Flutter plugin for:

Android

For Android check that the minSdkVersion in <YOUR_APP>/build.gradle is ≥21

iOS

The targeted OS version should be a minimum of 12+.

Add the following to info.plist:

  <key>NSCameraUsageDescription</key>
  <string>Mati verification SDK requires camera use</string>

  <key>NSMicrophoneUsageDescription</key>
  <string>Mati verification SDK requires microphone use</string>

  <key>NSPhotoLibraryUsageDescription</key>
  <string>Mati verification SDK requires access to media library</string>

Implement Mati in Your App

To start the Mati verification flow, call the following when the user taps on the Mati button:

  MatiFlutter.showMatiFlow(CLIENT_ID, FLOW_ID, METADATA)

The verification results will arrive in MatiFlutter.resultCompleter.future in a reply similar to the following:

MatiFlutter.resultCompleter.future.then((result) => Fluttertoast.showToast(
      msg: result is ResultSuccess ? "Success ${result.verificationId}" : "Cancelled",
      toastLength: Toast.LENGTH_SHORT,
      gravity: ToastGravity.BOTTOM));

Example Application

The following is an example application (MyApp) with the Mati verification flow:

import 'package:flutter/material.dart';
import 'package:mati_plugin_flutter/mati_plugin_flutter.dart';
import 'package:fluttertoast/fluttertoast.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Mati flutter plugin demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  void showMatiFlow() {
    MatiFlutter.showMatiFlow("CLIENT_ID", "FLOW_ID", {});
    MatiFlutter.resultCompleter.future.then((result) => Fluttertoast.showToast(
        msg: result is ResultSuccess ? "Success ${result.verificationId}" : "Cancelled",
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.BOTTOM));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Mati flutter plugin demo"),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: showMatiFlow,
          child: const Text('Verify me'),
        )
      )
    );
  }
}

Did this page help you?