Flutter Crash Restarter Plugin
A flutter plugin that restarts your Android app after a crash and provides you with the stack trace
Getting Started
Add this code inside the MainActivity class in your project on android/app/src/main/kotlin/com/your_company/your_package_name/MainActivity.kt
override fun onCreate(savedInstanceState: android.os.Bundle?) {
super.onCreate(savedInstanceState)
com.lucaszanella.flutterplugincrashrestartkt.FlutterExceptionHandler(MainActivity::class.java, this)
}
You can see how to get the stack trace on the example app in main.dart, or simply do:
import 'package:flutterplugincrashrestarter/flutterplugincrashrestarter.dart';
//...
void getStackTrace() async {
dynamic x = await Flutterplugincrashrestarter.getStackTrace();
if (x==false) {
//Did not recover from a crash, normal startup
} else if(x is Map) {
print("stack trace received");
if (x["didCrash"]) {
print("cause" + x["cause"]);
print("message: " + x["message"]);
print("stack trace: " + x["stackTrace"]);
}
}
}
You can also simulate a crash:
Flutterplugincrashrestarter.crash();