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

升级Flutter 3.24后Web应用在Chrome运行报mapEquals未定义错误

Flutter 3.24升级后Chrome运行新项目出现JSNoSuchMethodError异常

升级Flutter至3.24版本后,创建全新应用并在Chrome浏览器运行时,控制台抛出JSNoSuchMethodError异常,核心错误提示为TypeError: Cannot read properties of undefined (reading 'mapEquals'),报错关联组件为MaterialApp。

完整错误栈信息

The following JSNoSuchMethodError was thrown building NotificationListener<NavigationNotification>:
TypeError: Cannot read properties of undefined (reading 'mapEquals')

The relevant error-causing widget was:
  MaterialApp
  MaterialApp:file:///C:/Users/Munsif%20Ali/Desktop/Optemas/referee_dashboard/lib/main.dart:14:18

When the exception was thrown, this was the stack:
packages/flutter/src/widgets/shortcuts.dart 834:10                       set shortcuts
shortcuts.dart:834
packages/flutter/src/widgets/shortcuts.dart 1076:7                       initState
shortcuts.dart:1076
packages/flutter/src/widgets/framework.dart 5748:55                      [_firstBuild]
framework.dart:5748
packages/flutter/src/widgets/framework.dart 5593:5                       mount
framework.dart:5593
packages/flutter/src/widgets/framework.dart 4468:15                      inflateWidget
framework.dart:4468
packages/flutter/src/widgets/framework.dart 3963:18                      updateChild
framework.dart:3963
packages/flutter/src/widgets/framework.dart 5642:16                      performRebuild
framework.dart:5642
packages/flutter/src/widgets/framework.dart 5333:7                       rebuild
framework.dart:5333
packages/flutter/src/widgets/framework.dart 5599:5                       [_firstBuild]
framework.dart:5599
packages/flutter/src/widgets/framework.dart 5593:5                       mount
framework.dart:5593
packages/flutter/src/widgets/framework.dart 4468:15                      inflateWidget
framework.dart:4468
packages/flutter/src/widgets/framework.dart 3963:18                      updateChild
framework.dart:3963
packages/flutter/src/widgets/framework.dart 5642:16                      performRebuild
framework.dart:5642
packages/flutter/src/widgets/framework.dart 5333:7                       rebuild
framework.dart:5333
packages/flutter/src/widgets/framework.dart 5599:5                       [_firstBuild]
framework.dart:5599
packages/flutter/src/widgets/framework.dart 5593:5                       mount
framework.dart:5593
packages/flutter/src/widgets/framework.dart 4468:15                      inflateWidget
framework.dart:4468
packages/flutter/src/widgets/framework.dart 3963:18                      updateChild
framework.dart:3963
packages/flutter/src/widgets/framework.dart 5642:16                      performRebuild
framework.dart:5642
packages/flutter/src/widgets/framework.dart 5780:11                      performRebuild
framework.dart:5780
packages/flutter/src/widgets/framework.dart 5333:7                       rebuild
framework.dart:5333
packages/flutter/src/widgets/framework.dart 5599:5                       [_firstBuild]
framework.dart:5599
packages/flutter/src/widgets/framework.dart 5771:11                      [_firstBuild]
framework.dart:5771
packages/flutter/src/widgets/framework.dart 5593:5                       mount
framework.dart:5593
packages/flutter/src/widgets/framework.dart 4468:15                      inflateWidget
framework.dart:4468
packages/flutter/src/widgets/framework.dart 3963:18                      updateChild
framework.dart:3963
packages/flutter/src/widgets/framework.dart 5642:16                      performRebuild
framework.dart:5642
packages/flutter/src/widgets/framework.dart 5333:7                       rebuild
framework.dart:5333
packages/flutter/src/widgets/framework.dart 5599:5                       [_firstBuild]
framework.dart:5599
packages/flutter/src/widgets/framework.dart 5593:5                       mount
framework.dart:5593
packages/flutter/src/widgets/framework.dart 4468:15                      inflateWidget
framework.dart:4468
packages/flutter/src/widgets/framework.dart 3963:18                      updateChild
framework.dart:3963
packages/flutter/src/widgets/framework.dart 5642:16                      performRebuild
framework.dart:5642
packages/flutter/src/widgets/framework.dart 5780:11                      performRebuild
framework.dart:5780
packages/flutter/src/widgets/framework.dart 5333:7                       rebuild
framework.dart:5333
packages/flutter/src/widgets/framework.dart 5599:5                       [_firstBuild]
framework.dart:5599
packages/flutter/src/widgets/framework.dart 5771:11                      [_firstBuild]
framework.dart:5771
packages/flutter/src/widgets/framework.dart 5593:5                       mount
framework.dart:5593
packages/flutter/src/widgets/framework.dart 4468:15                      inflateWidget
framework.dart:4468
packages/flutter/src/widgets/framework.dart 3963:18                      updateChild
framework.dart:3963
packages/flutter/src/widgets/framework.dart 5642:16                      performRebuild
framework.dart:5642
packages/flutter/src/widgets/framework.dart 5333:7                       rebuild
framework.dart:5333
packages/flutter/src/widgets/framework.dart 5599:5                       [_firstBuild]
framework.dart:5599
packages/flutter/src/widgets/framework.dart 5593:5                       mount
framework.dart:5593
packages/flutter/src/widgets/framework.dart 4468:15                      inflateWidget
framework.dart:4468
packages/flutter/src/widgets/framework.dart 3963:18                      updateChild
framework.dart:3963
packages/flutter/src/widgets/framework.dart 5642:16                      performRebuild
framework.dart:5642
packages/flutter/src/widgets/framework.dart 5780:11    

应用代码

import 'package:flutter/material.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Home(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Hello World'),
      ),
      body: const Center(
        child: Text('Hello World'),
      ),
    );
  }
}

错误截图

错误截图

解决方案

  • 清理项目缓存:执行flutter clean,随后运行flutter pub get重新拉取依赖
  • 重新构建web项目:执行flutter run -d chrome --release或直接重启调试服务
  • 强制升级Flutter SDK:运行flutter upgrade --force确保SDK更新完整
  • 排除浏览器缓存影响:使用Chrome无痕模式运行项目,或手动清除浏览器缓存

内容的提问来源于stack exchange,提问作者Munsif Ali

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 23:05:57