From 174bbf254bd66c9d39f215cf8d6da386e73c6e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Uek=C3=B6tter?= Date: Mon, 22 Jan 2024 19:24:38 +0100 Subject: [PATCH] Add documentation which explains that `debugPrint` also logs in release mode (#141595) It's confusing that `debugPrint` also prints in release mode, given that a lot (most?) other things prefixed with `debug` don't do anything in release mode. Therefore, this adds some documentation that this is indeed logging in release mode and adds an example how to disable this. *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* --- packages/flutter/lib/src/foundation/print.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/flutter/lib/src/foundation/print.dart b/packages/flutter/lib/src/foundation/print.dart index 25b6c8f291..6b7d86da58 100644 --- a/packages/flutter/lib/src/foundation/print.dart +++ b/packages/flutter/lib/src/foundation/print.dart @@ -31,6 +31,14 @@ typedef DebugPrintCallback = void Function(String? message, { int? wrapWidth }); /// Prints a message to the console, which you can access using the "flutter" /// tool's "logs" command ("flutter logs"). /// +/// The [debugPrint] function logs to console even in [release mode](https://docs.flutter.dev/testing/build-modes#release). +/// As per convention, calls to [debugPrint] should be within a debug mode check or an assert: +/// ```dart +/// if (kDebugMode) { +/// debugPrint('A useful message'); +/// } +/// ``` +/// /// See also: /// /// * [DebugPrintCallback], for function parameters and usage details.