Skip to content

ValueKey<T>(..).toString() doesn't work in Release mode, gives response as Instance of 'ValueKey<T>' in 3.22.0 and 3.22.1 #148983

@kushalmahapatro

Description

@kushalmahapatro

Steps to reproduce

  1. Create a ValueKey
    const ValueKey<String> valueKey = ValueKey<String>('valueKey');
  2. Try to observe (print) the output of valuekey.toString() in debug and release mode
  3. In Debug it will print [<'valueKey'>]
  4. in Release it will print Instance of 'ValueKey<String>'

This is observed in 3.22.1 and 3.22.0 SDK version of Flutter.
But in 3.19.6 the output for the same is [<'valueKey'>] in both Release and Debug mode.

Expected results

[<'valueKey'>] should be the Expected Result in both Debug and Release mode as it used to be in 3.19.6 Flutter SDK

Actual results

Instance of 'ValueKey<String>' is the result that we are getting from the Release build made from 3.22.0 and 3.22.1 Flutter SDK, but in Debug mode it gives out [<'valueKey'>].

Code sample

Code sample
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    const ValueKey<String> valueKey = ValueKey<String>('valueKey');
    print(valueKey.toString());
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: RichText(
            textAlign: TextAlign.center,
            text: TextSpan(
              style: const TextStyle(color: Colors.black, height: 1.5),
              children: [
                const TextSpan(
                  text: "Mode: ${kReleaseMode ? 'Release' : 'Debug'} \n",
                ),
                TextSpan(
                  text: valueKey.toString(),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Debug Mode:
image

Release Mode:
image

Logs

Logs

3.22.1 - Release Mode

╰─○ flutter --version                      
Flutter 3.22.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision a14f74ff3a (26 hours ago) • 2024-05-22 11:08:21 -0500
Engine • revision 55eae6864b
Tools • Dart 3.4.1 • DevTools 2.34.3
╭─kushalmahapatro at Kushal’s MacBook Pro-14.2 in ~/Documents/App/value_key 24-05-23 - 21:57:40
╰─○ flutter run -d 2A131FDH30081D --release
Launching lib/main.dart on Pixel 7 Pro in release mode...
Running Gradle task 'assembleRelease'...                         1,483ms
✓ Built build/app/outputs/flutter-apk/app-release.apk (9.6MB)

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
I/flutter ( 5828): Instance of 'ValueKey<String>'

3.22.1 - Debug Mode

╰─○ flutter --version                      
Flutter 3.22.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision a14f74ff3a (26 hours ago) • 2024-05-22 11:08:21 -0500
Engine • revision 55eae6864b
Tools • Dart 3.4.1 • DevTools 2.34.3
╭─kushalmahapatro at Kushal’s MacBook Pro-14.2 in ~/Documents/App/value_key 24-05-23 - 21:58:18
╰─○ flutter run -d 2A131FDH30081D --debug  
Launching lib/main.dart on Pixel 7 Pro in debug mode...
Running Gradle task 'assembleDebug'...                              6.8s
✓ Built build/app/outputs/flutter-apk/app-debug.apk
Installing build/app/outputs/flutter-apk/app-debug.apk...           5.9s
I/flutter ( 6047): [<'valueKey'>]
Syncing files to device Pixel 7 Pro...                             127ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

A Dart VM Service on Pixel 7 Pro is available at: http://127.0.0.1:60257/3Gpy2R_nttw=/
The Flutter DevTools debugger and profiler on Pixel 7 Pro is available at:
http://127.0.0.1:9102?uri=http://127.0.0.1:60257/3Gpy2R_nttw=/
D/VRI[MainActivity]( 6341): Draw frame after cancel

3.22.0 - Release Mode

╰─○ flutter --version                      
Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5dcb86f68f (2 weeks ago) • 2024-05-09 07:39:20 -0500
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.3
╭─kushalmahapatro at Kushal’s MacBook Pro-14.2 in ~/Documents/App/value_key 24-05-23 - 22:19:50
╰─○ flutter run -d 2A131FDH30081D --release
Launching lib/main.dart on Pixel 7 Pro in release mode...
Running Gradle task 'assembleRelease'...                         2,111ms
✓ Built build/app/outputs/flutter-apk/app-release.apk (7.0MB)

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
I/flutter ( 7759): Instance of 'ValueKey<String>'

3.22.0 - Debug Mode

╰─○ flutter --version                     
Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5dcb86f68f (2 weeks ago) • 2024-05-09 07:39:20 -0500
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.3
╭─kushalmahapatro at Kushal’s MacBook Pro-14.2 in ~/Documents/App/value_key 24-05-23 - 22:20:36
╰─○ flutter run -d 2A131FDH30081D --debug 
Launching lib/main.dart on Pixel 7 Pro in debug mode...
Running Gradle task 'assembleDebug'...                             14.9s
✓ Built build/app/outputs/flutter-apk/app-debug.apk
Installing build/app/outputs/flutter-apk/app-debug.apk...           4.8s
I/flutter ( 7940): [<'valueKey'>]
D/VRI[MainActivity]( 7940): Draw frame after cancel
Syncing files to device Pixel 7 Pro...                             132ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

A Dart VM Service on Pixel 7 Pro is available at: http://127.0.0.1:62358/jOVqCulx-hU=/
The Flutter DevTools debugger and profiler on Pixel 7 Pro is available at:
http://127.0.0.1:9102?uri=http://127.0.0.1:62358/jOVqCulx-hU=/

3.19.6 - Release Mode

╰─○ flutter --version                    
Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 54e66469a9 (5 weeks ago) • 2024-04-17 13:08:03 -0700
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1
╭─kushalmahapatro at Kushal’s MacBook Pro-14.2 in ~/Documents/App/value_key 24-05-23 - 22:10:36
╰─○ flutter run -d 2A131FDH30081D --release
Launching lib/main.dart on Pixel 7 Pro in release mode...
Running Gradle task 'assembleRelease'...                           24.4s
✓  Built build/app/outputs/flutter-apk/app-release.apk (9.1MB).
Installing build/app/outputs/flutter-apk/app-release.apk...      2,098ms

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
I/flutter ( 7147): [<'valueKey'>]

3.19.6 - Debug Mode

╰─○ flutter --version                    
Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 54e66469a9 (5 weeks ago) • 2024-04-17 13:08:03 -0700
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1
╭─kushalmahapatro at Kushal’s MacBook Pro-14.2 in ~/Documents/App/value_key 24-05-23 - 22:09:55
╰─○ flutter run -d 2A131FDH30081D --debug
Launching lib/main.dart on Pixel 7 Pro in debug mode...
Running Gradle task 'assembleDebug'...                              3.0s
✓  Built build/app/outputs/flutter-apk/app-debug.apk.
I/flutter ( 6924): [<'valueKey'>]
Syncing files to device Pixel 7 Pro...                              38ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

A Dart VM Service on Pixel 7 Pro is available at: http://127.0.0.1:61210/rVXRmpwwLcA=/
The Flutter DevTools debugger and profiler on Pixel 7 Pro is available at:
http://127.0.0.1:9102?uri=http://127.0.0.1:61210/rVXRmpwwLcA=/
D/VRI[MainActivity]( 6924): Draw frame after cancel

Flutter Doctor output

Doctor output

3.22.1

╰─○ flutter doctor -v
[✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F5049f darwin-arm64, locale en-AE)
    • Flutter version 3.22.1 on channel stable at /Users/kushalmahapatro/fvm/versions/3.22.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (26 hours ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/kushalmahapatro/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio Preview.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (6 available)
    • Pixel 7 Pro (mobile)            • 2A131FDH30081D                       • android-arm64  • Android 14 (API 34)
    • Kushal’s iPhone 15 Pro (mobile) • 00008130-000A49381110001C            • ios            • iOS 17.5.1 21F90
    • iPhone 15 Pro Max (mobile)      • 4D68A564-705B-44F8-A643-C5D20E4A3DCB • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.5 23F5049f
      darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.5 23F5049f
      darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 124.0.6367.210

[✓] Network resources
    • All expected network resources are available.

• No issues found!

3.22.0

╰─○ flutter doctor -v
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.5 23F5049f darwin-arm64, locale en-AE)
    • Flutter version 3.22.0 on channel stable at /Users/kushalmahapatro/fvm/versions/3.22.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (2 weeks ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/kushalmahapatro/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio Preview.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (6 available)
    • Pixel 7 Pro (mobile)            • 2A131FDH30081D                       • android-arm64  • Android 14 (API 34)
    • Kushal’s iPhone 15 Pro (mobile) • 00008130-000A49381110001C            • ios            • iOS 17.5.1 21F90
    • iPhone 15 Pro Max (mobile)      • 4D68A564-705B-44F8-A643-C5D20E4A3DCB • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.5 23F5049f
      darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.5 23F5049f
      darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 124.0.6367.210

[✓] Network resources
    • All expected network resources are available.

• No issues found!

3.19.6

╰─○ flutter doctor -v
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.5 23F5049f darwin-arm64, locale en-AE)
    • Flutter version 3.19.6 on channel stable at /Users/kushalmahapatro/fvm/versions/3.19.6
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (5 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/kushalmahapatro/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio Preview.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (5 available)
    • Pixel 7 Pro (mobile)            • 2A131FDH30081D                       • android-arm64  • Android 14 (API 34)
    • Kushal’s iPhone 15 Pro (mobile) • 00008130-000A49381110001C            • ios            • iOS 17.5.1 21F90
    • iPhone 15 Pro Max (mobile)      • 4D68A564-705B-44F8-A643-C5D20E4A3DCB • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.5 23F5049f
      darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 124.0.6367.210

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: regressionIt was better in the past than it is nowfound in release: 3.22Found to occur in 3.22found in release: 3.23Found to occur in 3.23frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions