Print large strings in Flutter
Jul 4, 2021
If you get kind of frustrated when debugging. Fetched a resource from an API and wanted to print the JSON string to the console, but it kept cutting off the string.
Example:
Here is my solution, you can make your own print. Define this method
/// Print Long String
void printLongString(String text) {
final RegExp pattern = RegExp('.{1,800}'); // 800 is the size of each chunk
pattern.allMatches(text).forEach((RegExpMatch match) => print(match.group(0)));
}
Use it like:
printLongString('Your long string...');