flutter_rasp_guard 0.1.0
flutter_rasp_guard: ^0.1.0 copied to clipboard
Runtime Application Self-Protection (RASP) for Flutter. Native root, jailbreak, instrumentation, hooking, debugger and integrity detection, with a security gate that decides in native code whether the [...]
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_rasp_guard/flutter_rasp_guard.dart';
import 'screens/home_screen.dart';
import 'security_service.dart';
/// Reference integration for the RASP Security SDK.
///
/// This is a security gate, not a dashboard. On a device that fails the
/// verdict, `HomeScreen` is never built — the application UI is unreachable,
/// not merely covered.
///
/// The order below is the integration contract:
///
/// 1. **Initialise before `runApp`.** The native core has been running since
/// before `main()`, but policy is not committed until you commit it, and
/// the install deadline is counting.
/// 2. **Let `RaspGate` decide what renders.** The verdict is computed in
/// native code; Dart only draws the result.
/// 3. **Collect the kill report.** If the SDK terminated the previous run,
/// this is the only place you will ever learn why.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// The production profile is a gate: on a release build the app will not open
// with USB debugging on, a debugger attached, root/jailbreak present,
// instrumentation or hooking detected, or integrity verification failing.
//
// That means a DEBUG build blocks on a developer's own machine, because USB
// debugging is always on there. Swap in RaspConfiguration.development() for
// day-to-day work; this example uses production() so the gate is what you
// actually see.
await SecurityService.instance.start(const RaspConfiguration.production());
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'RASP Example',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFF3A6EA5),
brightness: Brightness.dark,
),
useMaterial3: true,
),
// THE SECURITY GATE.
//
// Wraps the whole application. `HomeScreen` is constructed only when the
// native verdict passes — a blocked device never reaches the app's own
// widget tree at all, so nothing in its initState runs either.
home: RaspGate(
onVerdict: SecurityService.instance.recordVerdict,
child: const HomeScreen(),
),
);
}
}