Skip to content
Back to Docs

Mobile SDK

Flutter

Cross-platform device fingerprinting, bot detection, and threat intelligence for iOS and Android.

Add to pubspec.yaml

pubspec.yaml
dependencies:
  lrdefender: ^1.0.0

Platform-specific setup

The Flutter plugin wraps the native LRDefender SDKs. Requirements: Flutter ≥ 3.13, Dart ≥ 3.3.

Android

Add the Maven artifact to your app module.

build.gradle.kts
// android/app/build.gradle.kts
dependencies {
    implementation("com.lightningresearch:sdk:2.0.0")
}

iOS

Link the Swift package and install CocoaPods.

terminal
# Add the LRDefender Swift package in Xcode
cd ios && pod install

LRDefender.init()

Initialize once before any API calls. Then use identify(), detectBot(), and assessThreat().

main.dart
import 'package:lrdefender/lrdefender.dart';

Future<void> bootstrap() async {
  await LRDefender.init(apiKey: 'lr_your_api_key', region: 'auto');

  final identity = await LRDefender.identify(tag: 'login');
  print('Device: ${identity.deviceId}');
  print('Risk: ${identity.risk.level}');

  final bot = await LRDefender.detectBot();
  if (bot.isBot) {
    // challenge or block
  }

  final threat = await LRDefender.assessThreat();
  if (threat.isVpn || threat.isProxy) {
    // elevated friction
  }
}

API reference

Method
Returns
LRDefender.init({apiKey, region?})
Future<void>
LRDefender.identify({tag?, linkedId?})
DeviceIdentity
LRDefender.detectBot()
BotResult
LRDefender.assessThreat()
ThreatResult
error-handling.dart
try {
  final identity = await LRDefender.identify();
} on LRDefenderError catch (error) {
  print('${error.code}: ${error.message}');
}

// Common codes: CONFIG_ERROR, NOT_INITIALIZED, AUTH_ERROR,
// RATE_LIMITED, NETWORK_ERROR, TIMEOUT