从 Flutter 记录大字符串 [英] Logging large strings from Flutter

查看:41
本文介绍了从 Flutter 记录大字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个 Flutter 应用程序并在此过程中学习 Dart,但在调试时我有点沮丧.我从 API 获取了一个资源,现在我想将 JSON 字符串打印到控制台,但它一直在切断字符串.

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 to print the JSON string to the console, but it keeps cutting off the string.

所以我实际上有两个问题:终端控制台真的是打印调试消息的唯一方法吗?如何将大字符串打印到控制台而不自动被切断?

So I actually have two questions: is the terminal console really the only way to print debug messages and how can I print large strings to the console without them automatically getting cut off?

推荐答案

如何使用 dart: developer 库中的 Flutter 日志.这似乎没有像 print()debugPrint() 那样的最大长度限制.这是似乎工作正常的唯一解决方案.尝试如下:

How about using the Flutter log from the dart: developer library. This does not seem to have the maximum length limit like print() or debugPrint(). This is the only solution that seems to work fine. Try it as below:

log(reallyReallyLongText)

输出将是没有中断的整个长字符串,并以[log]

The output will be the entire long string without breaks and prefixed with [log]

这篇关于从 Flutter 记录大字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆