native_crash 2.0.0 copy "native_crash: ^2.0.0" to clipboard
native_crash: ^2.0.0 copied to clipboard

Flutter plugin to simulate native crash. By calling crash it will crash the app.

native_crash #

A Flutter plugin to simulate native crash. Also can be used to check jailbreak/root/debug/emulator status.

Getting Started #

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

dependencies:
  native_crash: ^2.0.0

Requirements #

Minimum
Flutter 3.47.0
Dart 3.13.0
Android minSdk 24, AGP 9 / Gradle 9 (Java 17)
iOS 15.0, Swift Package Manager

CocoaPods is no longer supported on iOS. Android native libraries are 16 KB page-size aligned.

IOS Setup #

add the following to your ios/Runner/Info.plist file:

  <key>LSApplicationQueriesSchemes</key>
	<array>
			<string>undecimus</string>
			<string>sileo</string>
			<string>zbra</string>
			<string>filza</string>
	</array>

Migrating from 1.x #

  1. Upgrade Flutter to 3.47.0 or newer.
  2. Make sure Swift Package Manager is enabled (flutter config --enable-swift-package-manager, on by default in recent Flutter).
  3. Raise your app's Android minSdk to 24 or higher.
  4. Remove any pod 'native_crash' references from your Podfile; no Dart API changes were made.

Usage #

import 'package:native_crash/native_crash.dart';

// Simulate a native crash.
void crash() {
  NativeCrash.crash();
}

Check if device is rooted/jailbroken #

import 'package:native_crash/native_crash.dart';

// Check if device is rooted/jailbroken.
bool isJailBroken = await NativeCrash.checkJailBreak();

Check if device is debuggable #

import 'package:native_crash/native_crash.dart';

// Check if device has developer mode enabled.
bool isDevMode = await NativeCrash.checkDevMode();

Check if device is emulator #

import 'package:native_crash/native_crash.dart';

// Check if device is emulator.
bool isEmulator = await NativeCrash.checkEmulator();

Crash app when device is rooted/jailbroken #

import 'package:native_crash/native_crash.dart';
 void main() {
   WidgetsFlutterBinding.ensureInitialized();
   crashOnJailBreak(
     () async {
       runApp(MyApp());
     },
     /// you can also provide a custom widget to show when jailbreak/root detected instead of crashing the app
     onRootJailBreakDetected:(){
        print("Root/Jailbreak detected");
        runApp(RootJailBreakApp());
     }
   );
 }

Crash app when device has developer mode enabled #

import 'package:native_crash/native_crash.dart';
 void main() {
   WidgetsFlutterBinding.ensureInitialized();
   crashOnDevMode(
     () async {
       runApp(MyApp());
     },
     /// you can also provide a custom widget to show when developer mode detected instead of crashing the app
     onDevModeDetected:(){
        print("Developer mode detected");
        runApp(DevModeApp());
     },
   );
 }

Crash app when device is emulator #

import 'package:native_crash/native_crash.dart';
 void main() {
   WidgetsFlutterBinding.ensureInitialized();
   crashOnEmulator(
     () async {
       runApp(MyApp());
     },
      /// you can also provide a custom widget to show when emulator detected instead of crashing the app
     onEmulatorDetected:(){
        print("Emulator detected");
        runApp(EmulatorApp());
     },
   );
 }