Skip to content

Commit

Permalink
Merge pull request #2 from kishormainali/updates
Browse files Browse the repository at this point in the history
feat: add support for custom widgets on root/dev/emulator mode
  • Loading branch information
kishormainali authored Aug 5, 2024
2 parents e844a00 + 313c9e3 commit 1a441a8
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 51 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
## 1.2.0

- added support for showing custom widget when emulator/root/jailbreak/developer mode detected.
- dependency updates

## 1.1.2

- dependency updates
- updated android compileSdkVersion to 34
- updated android minSdkVersion to 23

## 1.1.1

- fix ios build issue

## 1.1.0

- added `jailbreak` or `root` detection.
- added optional `message` parameter to crash() method.

Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import 'package:native_crash/native_crash.dart';
bool isDevMode = await NativeCrash.checkDevMode();
```


## Check if device is emulator

```dart
Expand All @@ -50,10 +49,8 @@ import 'package:native_crash/native_crash.dart';
bool isEmulator = await NativeCrash.checkEmulator();
```


## Crash app when device is rooted/jailbroken


```dart
import 'package:native_crash/native_crash.dart';
void main() {
Expand All @@ -62,11 +59,16 @@ import 'package:native_crash/native_crash.dart';
() 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
## Crash app when device has developer mode enabled

```dart
import 'package:native_crash/native_crash.dart';
Expand All @@ -76,6 +78,11 @@ import 'package:native_crash/native_crash.dart';
() 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());
},
);
}
```
Expand All @@ -90,7 +97,11 @@ import 'package:native_crash/native_crash.dart';
() 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());
},
);
}
```

2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ android {
}

dependencies {
implementation "androidx.annotation:annotation:1.7.1"
implementation "androidx.annotation:annotation:1.8.1"
implementation 'com.scottyab:rootbeer-lib:0.1.0'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.1.1'
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
2 changes: 1 addition & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.2.2' apply false
id "com.android.application" version '8.4.1' apply false
}

include ":app"
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/native_crash/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
integration_test: 13825b8a9334a850581300559b8839134b124670
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
IOSSecuritySuite: e764318117aabd1f894cbdfc5ac013a59352953d
native_crash: 38078b848b480892529f9bbca857497f4ce294b4

PODFILE CHECKSUM: 7be2f5f74864d463a8ad433546ed1de7e0f29aef

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
25 changes: 25 additions & 0 deletions example/lib/app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:flutter/material.dart';
import 'package:native_crash/native_crash.dart';

class App extends StatelessWidget {
const App({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: const Column(
children: [
FilledButton(
onPressed: NativeCrash.crash,
child: Text('Crash'),
),
],
),
),
);
}
}
31 changes: 31 additions & 0 deletions example/lib/main_dev_mode.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:native_crash/native_crash.dart';
import 'package:native_crash_example/app.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
crashOnDevMode(
() => runApp(const App()),
onDevModeDetected: () {
runApp(const DevModeApp());
},
);
}

class DevModeApp extends StatelessWidget {
const DevModeApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Dev Mode Detected'),
),
body: const Center(
child: Text('You have enabled developer mode on your device.'),
),
),
);
}
}
31 changes: 31 additions & 0 deletions example/lib/main_emulator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:native_crash/native_crash.dart';
import 'package:native_crash_example/app.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
crashOnEmulator(
() => runApp(const App()),
onEmulatorDetected: () {
runApp(const EmulatorApp());
},
);
}

class EmulatorApp extends StatelessWidget {
const EmulatorApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Emulator Detected'),
),
body: const Center(
child: Text('You are trying to run your app on an emulator.'),
),
),
);
}
}
31 changes: 31 additions & 0 deletions example/lib/main_jailbreak.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:native_crash/native_crash.dart';
import 'package:native_crash_example/app.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
crashOnJailBreak(
() => runApp(const App()),
onRootJailBreakDetected: () {
runApp(const JailBreakApp());
},
);
}

class JailBreakApp extends StatelessWidget {
const JailBreakApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('JailBreak Detected'),
),
body: const Center(
child: Text('You are trying to run your app on a jail broken/rooted device.'),
),
),
);
}
}
34 changes: 17 additions & 17 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ packages:
dependency: "direct main"
description:
name: cupertino_icons
sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
url: "https://pub.dev"
source: hosted
version: "1.0.6"
version: "1.0.8"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -102,26 +102,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.1"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -150,17 +150,17 @@ packages:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
native_crash:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.1.1"
version: "1.1.2"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -250,10 +250,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
vector_math:
dependency: transitive
description:
Expand All @@ -266,10 +266,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "14.2.1"
webdriver:
dependency: transitive
description:
Expand All @@ -279,5 +279,5 @@ packages:
source: hosted
version: "3.0.3"
sdks:
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.13.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
Loading

0 comments on commit 1a441a8

Please sign in to comment.