Flutter

Fingerprint Flutter is an official open-source library for the Flutter ecosystem. The package is also published at pub.dev package repository. This library supports Android, iOS, and web platforms.

Requirements

The Flutter SDK uses the Android and iOS SDKs under the hood, so it has the same minimum OS version requirements:

  • Android 5.0 (API level 21+) or higher
  • iOS 13+/tvOS 15+, Swift 5.7 or higher
  • Flutter 3.13 or higher
  • Dart 3.3 or higher

1. Install the plugin

Add fpjs_pro_plugin to the pubspec.yaml file in your Flutter app:

dependencies:
  flutter:
    sdk: flutter
  ...
  fpjs_pro_plugin: ^3.3.2

Run flutter pub get to download and install the package.

To use this plugin on the web, add the JavaScript agent loader <script> tag to the <head> of your HTML template inside the web/index.html file:

<head>
  <!-- ... -->
  <script src="assets/packages/fpjs_pro_plugin/web/index.js" defer></script>
</head>

2. Identify visitors

import 'package:flutter/material.dart';
import 'package:fpjs_pro_plugin/fpjs_pro_plugin.dart';
import 'package:fpjs_pro_plugin/error.dart';
import 'package:fpjs_pro_plugin/region.dart';

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

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    initFingerprint();
  }

  // Initialize Fingerprint
  void initFingerprint() async {
    await FpjsProPlugin.initFpjs(
      '<PUBLIC_API_KEY>', // insert your API key here
      region: Region.us, // Insert the data region of your Fingerprint workspace
    );
    identify();
  }

  // Identify visitor
  void identify() async {
    try {
      var visitorId = await FpjsProPlugin.getVisitorId();
      var visitorData = await FpjsProPlugin.getVisitorData();

      print('Visitor ID: $visitorId');
      print('Visitor data: $visitorData');
    } on FingerprintProError catch (e) {
      // Process the error
      print('Error identifying visitor: $e');
    }
  }

  // ...
}

Documentation

You can find the full documentation in the official GitHub repository. The repository also contains an example app demonstrating usage of the library.