'can I show custom title in Firebase Crashlytics when I record the error manually?

in my Firebase Crashlytics console, the display will be like this

enter image description here

I try to record the error using the code below

      FirebaseCrashlytics.instance.recordError(
        error,
        null, // I pass null for stackTrace argument in here
        reason: "Failed to create cart, createChildList method failed to be executed on cart.dart file.",
        fatal: false,
      );

the problem is .....

all error recorded using the code above will be displayed as firebase_crashlytics.dart - line 117

it is not descriptive enough. Could I possibly show the dart file name instead? like in the second and third row in the image above?

I suspect it is because I pass null on the stackTrace argument when I recording the error. the problem is, I am confused how to create stackTrace object to be passed on the recordError method

can I show custom title in Firebase Crashlytics when I record the error 'manually' like that ?



Solution 1:[1]

yup, to show the error title in Crashlytics console, I have to pass the stack trace.

if you wanna show your page/screen name or dart file name, then you can pass the stackTrace like this

      FirebaseCrashlytics.instance.recordError(
        Exception("your exception message"),
        StackTrace.current, // you should pass stackTrace in here
        reason: "Error reason",
        fatal: false,
      );

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1