Kyaw Tun
Kyaw Tun

Reputation: 13131

How to send print log from flutter app?

How to get print console log and screen capture so that I can send stack trace to server?

Upvotes: 2

Views: 3798

Answers (2)

lu tang
lu tang

Reputation: 101

you can use f_logs package, this has a functionality on export logs to a directory on the phone, it has .db and .txt for the logs, and then you can use flutter_archive package to zip the file, and then use flutter_email_sender to send the zip file that contains the logs your development team. It worked for us, hope this will helps.

Upvotes: 0

Collin Jackson
Collin Jackson

Reputation: 116708

You can get a screenshot of the FlutterView using native code.

  • On Android: Bitmap screenshot = flutterView.getBitmap();
  • On iOS, see this example from Apple.

See the platform channels documentation on mixing Dart and native code.

As for the stack trace, here are some tips from the Flutter Sentry library documentation.

To get a stack trace from within Flutter, override the onError handler:

FlutterError.onError = (FlutterErrorDetails details) async {
  throw details;
};

To create a Zone with an error handler that catches all Dart exceptions, wrap your call to runApp in runZoned:

runZoned<Future<Null>>(() async {
  runApp(new MyApp());
}, onError: (error, stackTrace) async {
  if (error is FlutterErrorDetails) {
    // use error.exception and error.stack
  } else {
    // use error and stackTrace
  }
});

Upvotes: 5

Related Questions