Search code examples
flutterdart

Flutter Dart Try Catch Exception Line Number


how can i know the line number of the caught Exception inside try, catch ? here is my code:

try{
//your code here
} catch (Exception) {
    print('Exception '+Exception.toString());

  }

Solution

  • try{
    //your code here
    } catch (e, stacktrace) {
        print('Exception: ' + e.toString());
        print('Stacktrace: ' + stacktrace.toString());
    }