Skip to content

Commit 174bbf2

Browse files
authored
Add documentation which explains that debugPrint also logs in release mode (flutter#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].*
1 parent 5aa6cb8 commit 174bbf2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/flutter/lib/src/foundation/print.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ typedef DebugPrintCallback = void Function(String? message, { int? wrapWidth });
3131
/// Prints a message to the console, which you can access using the "flutter"
3232
/// tool's "logs" command ("flutter logs").
3333
///
34+
/// The [debugPrint] function logs to console even in [release mode](https://docs.flutter.dev/testing/build-modes#release).
35+
/// As per convention, calls to [debugPrint] should be within a debug mode check or an assert:
36+
/// ```dart
37+
/// if (kDebugMode) {
38+
/// debugPrint('A useful message');
39+
/// }
40+
/// ```
41+
///
3442
/// See also:
3543
///
3644
/// * [DebugPrintCallback], for function parameters and usage details.

0 commit comments

Comments
 (0)