1

I want to print large string in flutter but they are truncated.

Example, this is 1342 characters string:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad'); // minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Only the top 1022 characters will be printed.

I try to use debugPrint and print functions but nothing.

What I can do?

2
  • Why not use the debugger? Commented Dec 18, 2018 at 9:38
  • I need to print them on the console or redirect the output on text file (if possible). Commented Dec 18, 2018 at 9:46

2 Answers 2

1

That's due to VS Code truncating big strings, usually bigger than 1000 char of being printed at once. You can try a little "hack" by splitting it into words and print each of it.

myLongString.split(' ').forEach((word) => print(" " + word));

You can also try to use the logging package, but probably it will experience the same problem when trying to print the whole string, since it is trying to stdout all at once.

Sign up to request clarification or add additional context in comments.

Comments

0

you can use log(message) function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.