简体   繁体   English

print() 语句未在 Android Studio 中的 flutter iOS 应用程序中打印到控制台

[英]print() statement not printing to console in flutter iOS app within Android Studio

The print() statement is not printing any data within Android Studio's console in Flutter iOS version, but same code works fine for flutter android version. The print() statement is not printing any data within Android Studio's console in Flutter iOS version, but same code works fine for flutter android version.

Here is the flutter Doctor summary:这是 flutter 医生总结:

[✓] Flutter (Channel master, v1.10.7-pre.109, on Mac OS X 10.14.6 18G103, locale en-IN)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Community Edition (version 2019.1)
[✓] Connected device (1 available)

• No issues found!

I had the same issue.我遇到过同样的问题。 What worked for me was to add对我有用的是添加

import 'dart:developer';

to the top of my file, and then use到我文件的顶部,然后使用

log('your message here');

instead of print.而不是打印。

you should try你应该试试

debugPrint("")

to print in the console在控制台中打印

had same issue... embarrassing said that I had my debug console filtered without realize it.. after I remove the filter text I could see all my print() and log()有同样的问题......尴尬的是我在没有意识到的情况下过滤了我的调试控制台......在我删除过滤器文本后,我可以看到我所有的 print() 和 log()

I got the same issue.我遇到了同样的问题。

As a workaround:作为一种解决方法:

Select 'more actions' in the console, 'Open observatory' and the 'see debug' link. Select 控制台中的“更多操作”、“打开天文台”和“查看调试”链接。 Then you can see the outputs of the print statements.然后您可以看到打印语句的输出。

We stumbled upon it today and apparently the first line of some loggings doesn't appear.我们今天偶然发现了它,显然某些日志的第一行没有出现。 So if you start with a \n before your loggings it should work.因此,如果您在日志记录之前以\n开头,它应该可以工作。

os_log("\n  We're using this")

In my case this happened because I changed the display name in Xcode from Runner to something else.就我而言,这是因为我将 Xcode 中的显示名称从 Runner 更改为其他名称。 Everything was working fine, but there was no log output.一切正常,但没有日志 output。

On pubspec.yaml change:pubspec.yaml更改:

environment:
  sdk: ">=2.1.0 <3.0.0"

TO

environment:
  sdk: ">=2.6.0 <3.0.0"

Or high!或高!

To more information visit Dart Diagnostic欲了解更多信息,请访问Dart 诊断

For为了

[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2 21D49 darwin-x64, locale en-NG)
    • Flutter version 2.10.3 at /Users/theodore_mca/softwares_and_sdks/flutter2
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (6 days ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

Or Later或稍后

import 'dart:developer';

log("Theodore");

For regular strings对于常规字符串

import 'dart:developer';

  final Map<String, dynamic> value = {"email2":'_emailController.text',};
  value.addAll({
              "email":'_emailController.text',
               "username":'_usernameController.text'});
  
  log(value.toString());

For complex Data Type对于复杂的数据类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM