tbm98
tbm98

Reputation: 250

Does firebase_crashlytics work when using try / catch in flutter?

If use try / catch my application will not crash. But I want when the catch block to work, it also sends error information to firebase crashlytics console.

Upvotes: 8

Views: 3567

Answers (3)

tbm98
tbm98

Reputation: 250

I think solution are

  • Crashlytics.instance.log for log Single message, string.
  • Crashlytics.instance.recordError for log message error with stackTrace.
  • Crashlytics.instance.recordFlutterError for log message is generated by flutter framework

Upvotes: 8

Chris Papantonis
Chris Papantonis

Reputation: 739

Because the app doesn't crash it won't show any errors in crashlytics but you can report it manually.

Upvotes: 2

user3408531
user3408531

Reputation:

Inside the catch block send the error

catch(Exception e){
    Crashlytics.log(message);
    Crashlytics.logException(RunTimeExcption(message));
 }

Upvotes: 2

Related Questions