Print console debug in Android Studio flutter IOS

hello
When using android studio with android I can use print console function and it works well.
With a Mac and IOS, impossible to print in console.
Do somebody have a solution, Apple makes me crazy…smile
Regards and thanks
Vincent

How are you printing? Using print() or debugPrint()? Just asking this because debugPrint() is the function we have to use to print any messages in console.

import 'dart:developer'; then use this method:

// Emit a log event, which can can viewed using the DevTools
/// [Logging view](https://docs.flutter.dev/tools/devtools/logging).
///
/// This function was designed to map closely to the logging information
/// collected by `package:logging`.
///
/// - [message] is the log message
/// - [time] (optional) is the timestamp
/// - [sequenceNumber] (optional) is a monotonically increasing sequence number
/// - [level] (optional) is the severity level (a value between 0 and 2000); see
///   the `package:logging` `Level` class for an overview of the possible values
/// - [name] (optional) is the name of the source of the log message
/// - [zone] (optional) the zone where the log was emitted
/// - [error] (optional) an error object associated with this log event
/// - [stackTrace] (optional) a stack trace associated with this log event
external void log(
  String message, {
  DateTime? time,
  int? sequenceNumber,
  int level = 0,
  String name = '',
  Zone? zone,
  Object? error,
  StackTrace? stackTrace,
});

This will add the log to the default handler (which is used by logging | Dart package).

Using that standard, you can define where the log will be printed. What @kleyber said then can be used (debugPrint).

This has the advantage of capturing ALL log that is emitted by any packages that use the default logging package (which is made by the Dart team).

1 Like

Hello Kleyber. Thanks for your message. Just print in the console in the way to debug the code. Example…print(“step1 done”). Have tried debugPrint() and log without any success. No problem on android but Ios puts me in depression, will purchase Prozac…smile…

Also using that PRINT to check variables and modify my code in case of . Thank you for your help, I appreciafe

Hello. I have succeeded to make it working ( print and debugPrint) with the standard template ( when you create a new project with counter ). That means that I need to review all my code for Android ( that works perfectly ) for Ios. Ok for me, understood. So thanks for your help, your time and your attention for me, it helped me to find a solution, you gave me the HOPE and thanks again for it. Have a nice day and my really best regards to everybody. Vincent

2 Likes