搜尋套件、儲存庫與 APP 分類

套件詳情v1.2.1

flutter_liveness_detection_randomized_plugin

用於活體檢測的 Flutter 插件,採用隨機挑戰回應方法

AndroidiOS
近 30 天下載
203
喜歡數
64
Pub 分數
120

安裝套件

flutter pub add flutter_liveness_detection_randomized_plugin

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 插件,透過隨機挑戰-回應方法實現活體檢測,有助於驗證使用者在生物辨識認證過程中是否真實在場。此插件支援 Android 與 iOS 平台,可無縫整合至需要安全身分驗證的應用程式中。透過動態產生挑戰(例如,要求使用者眨眼或移動頭部),該插件可有效防止使用照片或影片進行偽造攻擊,從而提升安全性。專為開發金融、醫療或身分驗證系統類應用程式的開發者設計。

適用情境

  • 安全的用戶註冊
  • 生物識別認證
  • 身份驗證
  • 防止欺騙攻擊
  • 遠端KYC流程

主要特色

  • 隨機挑戰生成
  • 跨平台支援(Android 與 iOS)
  • 防偽機制
  • 與 Flutter 的簡單整合
  • 即時活體驗證

適合對象

  • 金融應用
  • 醫療保健平台
  • 政府服務
  • 電子商務身分驗證
  • 遠端帳戶註冊

使用建議

  • 需要相機存取權限
  • 取決於設備硬體品質
  • 可能需要針對不同的光照條件進行校準
  • 僅限前向攝像頭使用
  • 效能因舊設備而異

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Liveness Detection Randomized Plugin

A Flutter plugin for liveness detection with randomized challenge response method with an interaction mechanism between the user and the system in the form of a movement challenge that indicates life is detected on the face. This plugin helps implement secure biometric authentication by detecting real human presence through dynamic facial verification challenges.

pub package

Codacy Badge

Author

Crafted with love by Bagus Subagja ❤️

Feel free to fork and modify this package to suit your needs - that's much more enjoyable and respectful 😊

Preview 🪟

Slide 16_9 - 1

https://github.com/user-attachments/assets/f7266dc9-c4a2-4fba-8684-0ead2f678180

Update 1.2.1

  • ⬆️ Kotlin updated to 2.1.0 for better performance and support 16KB google page size policy
  • ⬆️ compileSdk & targetSdk bumped to 36 (Android 16)
  • ☕ Java & Kotlin JVM target upgraded to VERSION_17
  • 📱 minSdk raised to 24 (Android 7.0)
  • 🗑️ Removed useLegacyPackaging — no longer needed with modern AGP
  • 🔍 google_mlkit_face_detection updated to 0.13.2
  • 🐦 Flutter minimum version bumped to 3.38.7

Update 1.1.0

  • ⏱️ Added automatic cooldown feature after 3 failed verification attempts
  • 🔒 10-minute waiting period with persistent countdown (survives app restarts)
  • 🎯 Countdown only decreases when app is active (pauses when app is backgrounded)
  • 🔄 API Refactor: All parameters consolidated into LivenessDetectionConfig
  • 🎯 Simplified API - only requires context and config parameters
  • 🛠️ Fixed customizedLabel logic for proper skip challenge behavior
  • ✅ Added validation: customizedLabel must not be null when useCustomizedLabel is true

Update 1.0.6

Slide 16_9 - 9 Face stretching already fixed on this version

Features ✨

  • 📱 Real-time face detection
  • 🎲 Randomized challenge sequence generation
  • 💫 Cross-platform support (iOS & Android)
  • 🎨 Light and dark mode support
  • ✅ High accuracy liveness verification
  • 🚀 Simple integration API
  • 🎭 Customizable liveness challenge labels
  • ⏳ Flexible security verification duration
  • 🎲 Adjustable number of liveness challenges
  • 🛠️ Adjustable image quality result
  • ⏱️ Automatic cooldown after failed attempts

Getting Started 🌟

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_liveness_detection_randomized_plugin: ^1.2.1

Usage 🚀

final String? response = await FlutterLivenessDetectionRandomizedPlugin.instance.livenessDetection(
  context: context,
  config: LivenessDetectionConfig(
    // Camera & Image Settings
    cameraResolution: ResolutionPreset.medium, // Camera resolution
    imageQuality: 100, // Image quality (0-100)
    isEnableMaxBrightness: true, // Auto brightness adjustment
    
    // Detection Settings
    durationLivenessVerify: 60, // Detection timeout in seconds
    showDurationUiText: false, // Show countdown timer
    startWithInfoScreen: true, // Show tutorial screen
    
    // UI Settings
    isDarkMode: false, // Dark/light theme
    showCurrentStep: true, // Show step counter
    isEnableSnackBar: true, // Show result notifications
    shuffleListWithSmileLast: true, // Randomize challenges with smile last
    
    // Customization
    useCustomizedLabel: false, // Enable custom labels
    customizedLabel: LivenessDetectionLabelModel(
      blink: '', // Empty string = skip challenge
      lookDown: '', // Skip this challenge
      lookLeft: null, // null = use default "Look LEFT"
      lookRight: 'Turn Right', // Custom label
      lookUp: 'Look Up Please', // Custom label
      smile: null, // null = use default "Smile"
    ),
    
    // Security Features
    enableCooldownOnFailure: true, // Enable cooldown after failures
    maxFailedAttempts: 3, // Failed attempts before cooldown
    cooldownMinutes: 10, // Cooldown duration
  ),
);

Configuration Parameters 📋

Camera & Image Settings
  • cameraResolution: Camera quality (ResolutionPreset.low/medium/high)
  • imageQuality: Output image quality 0-100 (default: 100)
  • isEnableMaxBrightness: Auto brightness adjustment (default: true)
Detection Settings
  • durationLivenessVerify: Detection timeout in seconds (default: 45)
  • showDurationUiText: Show countdown timer (default: false)
  • startWithInfoScreen: Show tutorial before detection (default: false)
UI Settings
  • isDarkMode: Dark theme mode (default: true)
  • showCurrentStep: Show current step number (default: false)
  • isEnableSnackBar: Show success/failure notifications (default: true)
  • shuffleListWithSmileLast: Randomize challenges with smile at end (default: true)
Customization
  • useCustomizedLabel: Enable custom challenge labels (default: false)
  • customizedLabel: Custom labels for each challenge type
Security Features
  • enableCooldownOnFailure: Enable cooldown after failed attempts (default: true)
  • maxFailedAttempts: Number of failures before cooldown (default: 3)
  • cooldownMinutes: Cooldown duration in minutes (default: 10)

Cooldown Feature

The plugin includes an automatic cooldown mechanism to prevent brute force attempts:

  • Configurable number of failed attempts before cooldown
  • Configurable cooldown duration
  • Countdown timer only decreases when app is active
  • Cooldown state persists through app restarts
  • Users see a countdown screen during cooldown period

Customized Steps Label

You can customize challenge labels or skip certain challenges:

  • Use empty string '' to skip a challenge
  • Use null to keep default label
  • Provide custom string for personalized labels
  • When useCustomizedLabel: true, customizedLabel must not be null

Complete Example 💡

import 'package:flutter_liveness_detection_randomized_plugin/index.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              final result = await FlutterLivenessDetectionRandomizedPlugin.instance.livenessDetection(
                context: context,
                config: LivenessDetectionConfig(
                  startWithInfoScreen: true,
                  isDarkMode: false,
                  showCurrentStep: true,
                  isEnableSnackBar: true,
                ),
              );
              
              if (result != null) {
                // Liveness detection successful
                print('Face captured: $result');
              } else {
                // Detection failed or cancelled
                print('Detection failed');
              }
            },
            child: Text('Start Liveness Detection'),
          ),
        ),
      ),
    );
  }
}

Platform Setup

Android

Add camera permission to your android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA"/>

Minimum SDK version: 24

iOS

Add camera usage description to ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>Camera access is required for liveness detection</string>

Testing Scenarios 🧪

The example app includes 8 comprehensive liveness scenarios to test all features:

Scenario 1: Default Configuration
LivenessDetectionConfig(
  shuffleListWithSmileLast: true,
  startWithInfoScreen: true,
  // Standard settings
)
Scenario 2: Random Shuffle
LivenessDetectionConfig(
  shuffleListWithSmileLast: false,
  durationLivenessVerify: 30,
  startWithInfoScreen: false,
)
Scenario 3: Dark Mode + High Resolution
LivenessDetectionConfig(
  isDarkMode: true,
  cameraResolution: ResolutionPreset.high,
  durationLivenessVerify: 60,
)
Scenario 4: Custom Indonesian Labels
LivenessDetectionConfig(
  useCustomizedLabel: true,
  customizedLabel: LivenessDetectionLabelModel(
    blink: 'Kedip 2-3 Kali',
    lookUp: 'Lihat ke Atas',
    smile: 'Tersenyum Lebar',
  ),
)
Scenario 5: Skip Steps (Minimal Challenges)
LivenessDetectionConfig(
  useCustomizedLabel: true,
  customizedLabel: LivenessDetectionLabelModel(
    blink: 'Blink Eyes',
    lookDown: '', // Skip
    lookLeft: '', // Skip  
    lookRight: '', // Skip
    lookUp: 'Look Up Please',
    smile: 'Smile Wide',
  ),
)
Scenario 6: Timer + Cooldown Features
LivenessDetectionConfig(
  showDurationUiText: true,
  enableCooldownOnFailure: true,
  maxFailedAttempts: 2,
  cooldownMinutes: 5,
)
Scenario 7: Minimal Features
LivenessDetectionConfig(
  isEnableMaxBrightness: false,
  isEnableSnackBar: false,
  showCurrentStep: false,
)
Scenario 8: All Features Enabled
LivenessDetectionConfig(
  isDarkMode: true,
  cameraResolution: ResolutionPreset.high,
  showDurationUiText: true,
  enableCooldownOnFailure: true,
  useCustomizedLabel: true,
  customizedLabel: LivenessDetectionLabelModel(
    blink: '👁️ Kedipkan Mata',
    smile: '😊 Senyum Manis',
  ),
)

Migration Guide 🔄

From v1.0.x to v1.1.0+

All parameters are now consolidated into the LivenessDetectionConfig object:

Before:

await plugin.livenessDetection(
  context: context,
  config: LivenessDetectionConfig(...),
  isEnableSnackBar: true,
  shuffleListWithSmileLast: true,
  showCurrentStep: true,
  isDarkMode: false,
);

After:

await plugin.livenessDetection(
  context: context,
  config: LivenessDetectionConfig(
    isEnableSnackBar: true,
    shuffleListWithSmileLast: true,
    showCurrentStep: true,
    isDarkMode: false,
    // ... other parameters
  ),
);

所屬分類

依賴

依賴清單 10 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。