New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
print() statements in Flutter are truncated in flutter run output #22665
Comments
This took my hours to debug, because I was relying on logs and copying access token from there. I was using new experimental log window in Android Studio flutter plugin. No <..> truncation indication there sadly, so didn't realize truncation going on. |
I have met the same issue. I was trying to print access_token from oauth, but it's trunked. The iPhone X simulator was being used.
|
You can use debugPrint instead of print to log long text |
@SachinGanesh I used debugPrint also, but it doesn't work. |
Having this exact issue. I've resorted to a janky overlayed TextField that I can toggle on that mirrors the log output and is text-selectable. Really annoying. |
Can confirm that both |
@trevorwang then replace first statement with this |
@Suraj-Tiwari Thanks. will have a try. |
A slightly nicer workaround might be to create your own void printWrapped(String text) {
final pattern = new RegExp('.{1,800}'); // 800 is the size of each chunk
pattern.allMatches(text).forEach((match) => print(match.group(0)));
} (note: I haven't battle-tested that function but it worked in a quick test..). |
I had a very long json string to be printed out but in the console i saw a single string truncated so i used this method (if can be helpful for someone):
But it works only with json strings, i have not idea about how to do with "normal" strings. |
This comment has been minimized.
This comment has been minimized.
Same issue here. I have noticed a 1024 character limit in the console. |
any fixes for this issue yet ? |
workarounds but no proper fix.
|
I checked with full access token length and after printing it. There is a huge difference in size. |
plz fix this issue. |
So as it turns out, this isn't a bug in Flutter. It seems like this is a hard limitation set by the mobile platforms themselves. For iOS, there doesn't seem to be any kind of configuration for it but it does have a (very) dirty fix: For Android, there doesn't seem to be any fix. Only the workaround of the kind like DanTup mentioned: https://stackoverflow.com/questions/8888654/android-set-max-length-of-logcat-messages |
There is a second optional parameter in debugPrint you can use to wrap the log text: debugPrint(someSuperLongString, wrapWidth: 1024); |
This is the only workaround that can work easily right now. Thanks @DanTup |
when to fix it? so long time... |
This works perfectly. I set it to 1000 rather than 1024 to give some headroom as I wasn't clear whether the 'flutter:' prefix counted in the total, but it splits the message into multiple lines and everything is shown. Spot on! |
Can this issue be locked? It's become an endless cycle of people either requesting an update or posting the same fix/workaround. |
Any updates on print()? Having the same problem. |
I'm heading the same issue in Android Studio. Finally wrote a function for logging which splits the string into pieces:
|
you can see the full log output in the DevTools https://flutter.dev/docs/testing/debugging |
Hi folks, please see the solution here: #22665 (comment) |
Originally raised at Dart-Code/Dart-Code#1223 by @rajeshzmoke. If you
print()
a long string in Flutter, it gets truncated with<…>
in theflutter run
output:I'm using the iOS Simulator - it's possible this is a limitation of how we're reading the logs from the device, I'm not sure.
The text was updated successfully, but these errors were encountered: