Flutter SmartFace Plugin

A Flutter plugin by Visica that provides facial recognition capabilities for both Android and iOS platforms.

Table of Contents

Requirements

  • Flutter SDK: 3.24.0 or higher (3.29.3 stable recommended)
  • Dart SDK: 3.0.0 or higher (3.7.2 stable recommended)
  • Android: API level 24 (Android 7.0) or higher. The project targets/compiles against API 34, so installing the Android 34 SDK is recommended.
  • XCode: 15.0 or higher (for iOS development, 16.3 recommended)
  • iOS: 13.0 or higher (18.4 recommended)
    • ⚠️ WARNING: Only supports arm64 (physical devices) and x86_64 (iOS Simulator) architectures

Installation

Add the Flutter SmartFace plugin to your project's pubspec.yaml:

dependencies:
  flutter_smartface: ^<latest_version> # Check for the latest version on pub.dev

Then run:

flutter pub get

Platform Setup

Android Configuration

1. Configure Maven Repository

Modify your android/build.gradle file:

allprojects {
    repositories {
        google()
        mavenCentral()

        maven {
            url = uri(System.getenv("SMARTFACE_MAVEN_URL"))
            credentials {
                username = "Private-Token"
                password = System.getenv("SMARTFACE_MAVEN_TOKEN")
            }
        }
    }
}

Set the required environment variables:

macOS/Linux:

export SMARTFACE_MAVEN_URL="<your_maven_repo_url>"
export SMARTFACE_MAVEN_TOKEN="<your_auth_token>"

Add to your shell profile (~/.bash_profile, ~/.bashrc, or ~/.zshrc) to persist.

Windows:

  1. Right-click "This PC"Properties
  2. Click Advanced system settingsEnvironment Variables
  3. Add new variables:
    • SMARTFACE_MAVEN_URL
    • SMARTFACE_MAVEN_TOKEN
  4. Restart your IDE and terminal

2. Configure ProGuard

If using ProGuard for release builds, add to android/app/proguard-rules.pro:

-keepclassmembers class br.com.visica.sface.** {
  *;
}

iOS Configuration

1. Enable Swift Package Manager

Flutter's Swift Package Manager support is turned off by default. Enable it:

# Upgrade to latest Flutter
flutter upgrade

# Enable Swift Package Manager
flutter config --enable-swift-package-manager

# Verify it's enabled
flutter config --list | grep swift-package-manager
# Should show: enable-swift-package-manager: true

2. Configure Authentication

Configure Swift Package authentication by adding credentials to your ~/.netrc file:

# Create or edit .netrc file
echo "machine gitlab.com
  login <your_gitlab_login>
  password <your_gitlab_token>" >> ~/.netrc

# Set correct permissions
chmod 600 ~/.netrc

3. XCode Configuration

XCode will require Swift Package Manager authentication:

  1. Open your iOS project in XCode
  2. Navigate to XCode → Settings → Accounts
  3. Add your GitLab credentials when prompted

XCode GitLab Credentials

CI/CD Setup

For CI/CD environments, set these environment variables:

  • Android:

    • SMARTFACE_MAVEN_URL
    • SMARTFACE_MAVEN_TOKEN
  • iOS:

    • GITLAB_DEPLOY_USERNAME
    • GITLAB_DEPLOY_TOKEN

Getting Started

  1. Obtain Credentials

    Contact the Visica support team to request:

    • Maven repository URL and token (Android)
    • Swift package login and token (iOS)
  2. Configure Permissions

    iOS - Add to ios/Runner/Info.plist:

    <key>NSCameraUsageDescription</key>
    <string>This app needs camera access for facial recognition</string>
    

    Android - Add to android/app/src/main/AndroidManifest.xml:

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    
  3. Import and Use

    import 'package:flutter_smartface/flutter_smartface.dart';
    

    See the example directory for complete implementation details.

Troubleshooting

Common Issues

  1. "No such module 'SmartfaceMobile'" (iOS)

    • Ensure Swift Package Manager is enabled
    • Verify GitLab credentials in ~/.netrc
    • See Troubleshooting Guide
  2. Build failures (Android)

    • Verify environment variables are set
    • Restart IDE after setting variables
    • Check ProGuard configuration
  3. Authentication errors

    • Verify credentials with Visica support
    • Check file permissions on ~/.netrc

For detailed troubleshooting steps, see the Troubleshooting Guide.

Reporting Issues

When reporting issues, please use our Bug Report Template and include:

  • The diagnostic report generated above
  • Complete error messages
  • Steps to reproduce
  • Your Flutter environment details

Support

For technical assistance or credential requests:

  • Contact the Visica support team with your project details
  • Include your diagnostic report when requesting support

License

This plugin is provided under a commercial license. Contact Visica for license terms and usage permissions.