I am using VS code for Flutter programming, and I have noted that I do not always get a useful stack trace when there is an exception.
Below is a description of how you can make the reproducable error that I am describing below:
Generate a new project with the following command:
flutter create your_project_name
Then add the following Image widget in the generated main.dart :
Image.asset(
'non_existing_image.png',
),
Now when I am running the code and it stops at an exception for the incorrect image, I would expect the call stack to include the relevant line in my “main.dart” where I added the above Image widget.
But that does not happen as you can see below.
I was going to attach a screenshot but could not because “You need at least 10 reputation to post images.”
So instead I am pasting the call stack below as text:
ImmutableBuffer.fromAsset.<anonymous closure> (dart:ui/painting.dart:6688)
<asynchronous gap> (Unknown Source:0)
PlatformAssetBundle.loadBuffer (package:flutter/src/services/asset_bundle.dart:363)
<asynchronous gap> (Unknown Source:0)
AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:754)
<asynchronous gap> (Unknown Source:0)
So, what can I do about this?
Maybe there is some setting in VS code or the Flutter plugin where I can increase the number of stack frames to include, to hopefully also include the problem line in my own code?
Or some setting that makes sure to show more stack trace code instead of “asynchronous gap”?
user24331600 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.