I\'m trying to build a Flutter App and learning Dart in the process, but I\'m getting kind of frustrated when debugging. I have fetched a resource from an API and now I want
How about using the Flutter log from the dart: developer
library. This does not seem to be the maximum length limit like print()
or debugPrint()
. This is the only solution that seems to work fine. Try it as below:
log(reallyReallyLongText)
The output will be the entire long string without breaks and prefixed with [log]
If you run the application in android studio it will truncate long string.
In xcode 10.2 which i am using long string is not truncating.
My suggestion is write print statement logs and run the application in Xcode instead of android studio.
You can make your own print. Define this method
void printWrapped(String text) {
final pattern = RegExp('.{1,800}'); // 800 is the size of each chunk
pattern.allMatches(text).forEach((match) => print(match.group(0)));
}
Use it like
printWrapped("Your very long string ...");
Credit
Use debugPrint with the optional parameter to wrap according to the platform's output limit.
debugPrint(someSuperLongString, wrapWidth: 1024);
Use this method
JsonEncoder encoder = new JsonEncoder.withIndent(' ');
String prettyprint = encoder.convert(yourJsonString);
debugPrint(prettyprint);
But it works only with JSON strings, I have not idea about how to do with "normal" strings. The first thing I think is to add manually a \n after every n characters, for now, while waiting for a stable fix!
Please try debugPrint('your output');
instead of print('your output');
the documentation is here if you would like to read. debugPrint
throttles the output to a level to avoid being dropped by android's kernel as per the documentation.