LogView constructor

LogView(
  1. Widget child, {
  2. String? logEmail,
  3. bool showLogButton = true,
  4. void onFlutterError(
    1. FlutterErrorDetails error
    )?,
  5. void onZoneError(
    1. dynamic error,
    2. 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());
    }
  });
}