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

Flutter Web调试模式下随机TypeError编译崩溃问题求助

Flutter Web调试模式间歇性TypeError: Cannot read properties of undefined问题求助

正在为现有Flutter应用添加Web支持,调试模式下会间歇性触发TypeError: Cannot read properties of undefined (reading 'foo')错误,其中foo的内容随机变化,可能是插件相关类、自定义类或Flutter SDK类,该错误会直接导致应用编译崩溃。

已排查的线索:

  • 仅在调试模式下出现,Release模式无此问题
  • 在Flutter 3.27.4、3.29.0等多个版本中均存在
  • 错误发作无规律,无法稳定复现
  • 新建空白Flutter Web项目无法复现该问题
  • 曾出现main()函数被该错误影响的情况
  • 执行flutter clean命令后问题未得到解决

附项目的index.html代码:

<!DOCTYPE html>
<html>

<head>
  <!-- Base & Meta -->
  <base href="/">
  <meta charset="UTF-8" />
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">

  <!-- iOS Meta -->
  <meta name="mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <meta name="apple-mobile-web-app-title" content="deercast" />
  <link rel="apple-touch-icon" href="icons/Icon-192.png" />
  <link rel="icon" type="image/png" href="favicon.png" />
  <link rel="manifest" href="manifest.json" />
  <title>app_name</title>

  <!-- Styles -->
  <link rel="stylesheet" href="splash_style.css" />

  <!-- External Scripts -->
  <script src="gleap_loader.js" defer></script>
  <script src="splash_remover.js" defer></script>
  <script src="./assets/packages/mixpanel_flutter/assets/mixpanel.js" defer></script>

</head>

<body>
  <script src="flutter_bootstrap.js" defer></script>
</body>

</html>

内容的提问来源于stack exchange,提问作者Mehmet Karanlık

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 16:07:02