LogView constructor
LogView(
- Widget child, {
- String? logEmail,
- bool showLogButton = true,
- void onFlutterError(
- FlutterErrorDetails error
- void onZoneError(
- dynamic error,
- StackTrace stackTrace
Implementation
LogView(Widget child, {String? logEmail,bool showLogButton=true, void Function(FlutterErrorDetails error)? onFlutterError, void Function(dynamic error, StackTrace stackTrace)? onZoneError}) {
instance = this;
/*ErrorWidget.builder = (FlutterErrorDetails details) => _LogView(
Container(
color: Colors.red[400],
child: ListView(children: <Widget>[Text(details.exceptionAsString()+'\n\n'+details.stack.toString(), style: TextStyle(color:Colors.white))])
),
logEmail
);*/
FlutterError.onError = (FlutterErrorDetails details) async {
if(onFlutterError !=null)
try {
onFlutterError(details);
} catch(e) { print(e); }
else {
print(details.exceptionAsString());
LVERROR(details.exceptionAsString());
print(details.stack.toString());
LVERROR(details.stack.toString());
}
};
runZonedGuarded<Future<void>>(() async {
try {
runApp(_LogView(child,logEmail,showLogButton));
} catch(e) { print(e); }
}, (dynamic error, StackTrace stackTrace) {
if(onZoneError != null)
try {
onZoneError(error,stackTrace);
} catch(e) { print(e); }
else {
print(stackTrace.toString());
LVLOG(stackTrace.toString());
}
});
}