Skip to main content
This guide will help you set up and run the Verisoul Flutter Sample App, which demonstrates how to integrate Verisoul into a Flutter application.

About the Sample App

The Verisoul Flutter SDK is a demonstration project that showcases Verisoul’s fake user detection technology in a Flutter environment. The app includes:
  • Complete integration of Verisoul’s SDK for Flutter applications
  • Touch event tracking for both Android and iOS platforms
  • Cross-platform fraud detection capabilities

Prerequisites

Before you begin, you’ll need:
  • Flutter development environment set up
  • For Android: Android Studio and Android SDK
  • For iOS: Xcode and CocoaPods
  • A Verisoul Project ID (obtain this by scheduling a call)

Installation Steps

1. Add the Dependency

Add the Verisoul SDK to your project by updating your pubspec.yaml file:
dependencies:
  flutter:
    sdk: flutter
  # ... other dependencies
  verisoul_sdk: ^0.4.59
Run the following command to install the dependencies:
flutter pub get

2. Android Configuration

Update Minimum SDK Version

Update the Android minimum SDK version to 24 in your android/app/build.gradle file:
defaultConfig {
    minSdk = 24
    // ... other configurations
}

Add Maven Repository (if needed)

If you encounter build issues with the ai.verisoul:android package, add this Maven repository to your android/build.gradle file:
allprojects {
    repositories {
        // ... existing repositories
        maven { url = uri("https://us-central1-maven.pkg.dev/verisoul/android") }
    }
}

3. iOS Configuration

Add App Attest Capability

To fully utilize Verisoul SDK on iOS:
  1. Open your iOS project in Xcode
  2. Add the App Attest capability to your project
  3. Update your app’s entitlements file:
    <key>com.apple.developer.devicecheck.appattest-environment</key>
    <string>production</string> <!-- or development -->
    

Add Privacy Manifest

Create a PrivacyInfo.xcprivacy file in your iOS project with the required privacy settings for device ID collection and system boot time API access.

4. Web Support

Add the Verisoul script to your web/index.html:
<script async src="https://js.verisoul.ai/{env}/bundle.js" verisoul-project-id="{project_id}"></script>
Replace the following parameters:
  • : Use either prod or sandbox
  • : Your project ID, which must match the environment

Content Security Policy (CSP)

If your application has a Content Security Policy, update it to include the following Verisoul domains:
<meta http-equiv="Content-Security-Policy" content="script-src 'self' https://js.verisoul.ai; worker-src 'self' blob: data:;connect-src 'self' https://*.verisoul.ai wss://*.verisoul.ai;">

5. Implementation

Initialize the SDK

Initialize the Verisoul SDK in your main.dart file:
import 'package:verisoul_sdk/verisoul.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  VerisoulSdk.configure(
    projectId: "YOUR_PROJECT_ID", 
    environment: VerisoulEnvironment.prod
  );
  runApp(const MyApp());
}

Get Session ID

Retrieve the session ID when needed:
final session = await VerisoulSdk.getSessionApi();
print("Session ID: $session");

Provide Touch Events

Wrap your App with VerisoulWrapper:
runApp(VerisoulWrapper(child: const MyApp()));

Reinitialize

Calling VerisoulSdk.reinitialize() generates a new session_id, which ensures that if a user logs out of one account and into a different account, Verisoul will be able to delineate each account’s data cleanly.
await VerisoulSdk.reinitialize();

SetAccountData (Web-only)

The setAccountData() function provides a simplified way to send user account information to Verisoul directly from the client side. While easy to integrate, this method has important limitations:
  • Offline analysis only: Data sent via setAccountData() is only visible in the Verisoul dashboard
  • No real-time decisions: Unlike the server-side API, this method doesn’t allow your application to receive and act on Verisoul’s risk scores in real-time
  • Limited use case: Designed specifically for initial pilots and evaluation purposes
await VerisoulSdk.setAccountData(
  id: "example-id",
  email: "example@example.com",
  metadata: {"paid": true}
);

6. Platform-Specific Setup

Android Touch Events

For Android, modify your MainActivity.kt file to track touch events:
import ai.verisoul.sdk.Verisoul
import android.view.MotionEvent

class MainActivity: FlutterActivity() {
  override fun onTouchEvent(event: MotionEvent?): Boolean {
    Verisoul.onTouchEvent(event)
    return super.onTouchEvent(event)
  }
}

What to Expect

Once integrated, the Verisoul Flutter SDK will:
  • Collect touch events and device motion data on both Android and iOS
  • Generate a session ID for risk assessment
  • Upload necessary data to Verisoul’s backend
  • Provide cross-platform fraud detection for your Flutter application

Next Steps

After exploring the sample app, you can use it as a reference for implementing Verisoul in your own Flutter applications. For more detailed documentation, see the Verisoul Integration Guide.