Aravinth thiyagarajan
Aravinth thiyagarajan

Reputation: 2493

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.

Here is the flutter Doctor summary:

[✓] 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!

Upvotes: 34

Views: 43088

Answers (9)

Inquisitive Owl
Inquisitive Owl

Reputation: 19

I also faced print issues when running flutter app in iOS. There is a way that you can get all the log of the device using Xcode.

you should open like, Xcode -> window -> Devices and simulators -> select your device you're running -> Open console

this will open a window that will show whole log of the device and you can filter it with any keyword, even you can check keyword like contains, not-contain, equal and no-equal etc.

Upvotes: 0

Claudio Moscoso
Claudio Moscoso

Reputation: 387

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()

Upvotes: 12

Theodore MCA
Theodore MCA

Reputation: 1178

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

Upvotes: 0

On pubspec.yaml change:

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

Upvotes: 0

Julian Horst
Julian Horst

Reputation: 805

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.

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

Upvotes: 3

TimSim
TimSim

Reputation: 4036

In my case this happened because I changed the display name in Xcode from Runner to something else. Everything was working fine, but there was no log output.

Upvotes: 1

Bianco
Bianco

Reputation: 551

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.

Upvotes: 43

Marcel Verhagen
Marcel Verhagen

Reputation: 39

I got the same issue.

As a workaround:

Select 'more actions' in the console, 'Open observatory' and the 'see debug' link. Then you can see the outputs of the print statements.

Upvotes: 4

Mo Ok
Mo Ok

Reputation: 544

you should try

debugPrint("")

to print in the console

Upvotes: 10

Related Questions