Flutter print data with the exact file name and line number

Sometimes we need to print many test data from many pages. but from the console, it’s really hard to understand which data is printing from whereas like browser JS console log.

Yes, you can do it also with flutter. Simple use the below code to make it happen to form your side also.

debugPrintStack(label: "Label name", maxFrames: 2);
print('Data which you want to print');

Or you can also use this


print(StackTrace.current);

Now run and check your debug console.

It’s now easy to understand that it’s printing from there “package:nextcard/pages/dashboard_page.dart:460”

Thanks all, Happy coding 🙂