You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter 3.10升级后调试变量显示<optimized out>问题求助

Flutter 3.10升级后VS Code调试变量悬停异常的解决办法

问题描述

将Flutter从3.7版本升级到3.10版本后,在VS Code中调试时:

  • 断点可正常命中
  • 鼠标悬停查看任意变量值时,会显示< optimized out >< error >: < Invalid params >提示
  • 该问题在macOS、iOS模拟器、实体iPhone调试场景中均出现

已尝试但无效的修复步骤

  • 执行 flutter clean
  • 删除/ios、/macos目录下的Pods文件夹
  • 删除/ios、/macos目录下的Podfile.lock文件
  • 执行 flutter pub get
  • 进入ios、macos目录执行 pod install
  • 执行 flutter run
  • 删除Flutter SDK的bin/cache目录

临时替代方案

目前只能通过print语句输出变量值来查看。

环境信息

flutter doctor -v输出:

[✓] Flutter (Channel stable, 3.10.0, on macOS 13.3.1 22E772610a darwin-arm64, locale en-US)
    • Flutter version 3.10.0 on channel stable at /Users/aykut/Projects/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (8 days ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
    • Android SDK at /Users/aykut/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.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 11.0.15+0-b2043.56-8887301)

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 113.0.5672.92

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

• No issues found!

可行解决方案

方案1:降级VS Code Flutter扩展版本

Flutter扩展3.64.0与Flutter 3.10存在兼容性问题,降级到3.62.0版本:

  1. 打开VS Code扩展面板,找到Flutter扩展
  2. 点击扩展右下角的设置图标,选择「Install Another Version...」
  3. 选择3.62.0版本安装,重启VS Code后重新调试

方案2:修改调试配置禁用编译优化

在项目.vscode/launch.json中添加如下配置:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter",
            "request": "launch",
            "type": "dart",
            "args": ["--no-tree-shake-icons"],
            "flutterMode": "debug"
        }
    ]
}

保存后重启调试。

方案3:升级到Flutter 3.10.1及以上版本

Flutter 3.10.0存在调试相关已知bug,后续版本已修复,执行命令升级:

flutter upgrade

内容的提问来源于stack exchange,提问作者Aykut Ucar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 14:57:49