如何将数据记录到 Flutter 控制台? [英] How to log data to the Flutter console?

查看:29
本文介绍了如何将数据记录到 Flutter 控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个使用 IntelliJ IDEA 的初学者,我想将数据记录到控制台?

I am a beginner and using IntelliJ IDEA, and I wanted to log data to the console?

我尝试了 print()printDebug(),但 Flutter 控制台中没有显示任何数据.

I tried print() and printDebug(), but none of my data were showing in the Flutter console.

推荐答案

如果你在 Flutter Widget 中,你可以使用 debugPrint,例如

If you're inside a Flutter Widget, you can use debugPrint, e.g.,

import 'package:flutter/foundation.dart';

debugPrint('movieTitle: $movieTitle');


否则,您可以使用 Dart 内置的 log 功能

import 'dart:developer';

log('data: $data');

这篇关于如何将数据记录到 Flutter 控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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