crashOnDevMode function
This will kill your app when the device is in dev mode.
call this method in main method of your app.
void main() {
WidgetsFlutterBinding.ensureInitialized();
crashOnDevMode(
() async {
runApp(MyApp());
},
);
}
Implementation
Future<void> crashOnDevMode(
FutureOr<void> Function() builder, {
FutureOr<void> Function()? onDevModeDetected,
}) async {
bool isDevMode = await NativeCrash.checkDevMode();
if (isDevMode && kReleaseMode) {
if (onDevModeDetected != null) {
return onDevModeDetected();
} else {
await NativeCrash.crash(
'You have enabled developer mode on your device.');
return;
}
}
return builder();
}