How to get an error log from a physical device/productive app

400

As mentioned in the cookbook of Flutter, you can report errors to a service. Of course, you need to know which part of your code is throwing exceptions. You can print errors to the developer console in debug mode and send them to an API in production mode.

FlutterError.onError = (FlutterErrorDetails details) {
  if (isInDebugMode) {
    // In development mode, simply print to console.
    FlutterError.dumpErrorToConsole(details);
  } else {
    // In production mode, report to the application zone to report to
    // Sentry.
    Zone.current.handleUncaughtError(details.exception, details.stack);
  }
};

Share:
400
S-Man
Author by

S-Man

Author Advanced PostgreSQL Querying ISBN 978-3752967340

Updated on December 26, 2022

Comments

  • S-Man
    S-Man over 1 year

    I have an app that seems to throw a NullPointerException on very rare occasions. We have not been able to reproduce this in any development environment.

    Is there an internal log file or other way to read the error message when it occurs? For example, if a normal user who installed the app from the PlayStore/App Store gets the problem - is there a file or something the user could send us?

    Or what is the best practice with Flutter to handle such errors?

  • S-Man
    S-Man over 3 years
    So, if understand correctly: There's no way to read a local error log? Instead the user must allow sendings some error reports to an external service?