after upgrading flutter to 3.24
I created a brand new application and run it on chrome I am getting this exception in console
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
here is app code
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'),
),
);
}
}
2
Answers
The app has to work if you remove WidgetsFlutterBinding.ensureInitialized();
But how to avoid removing ensureInitialized I don’t know yet.
I have the same problem – but in fact I get different errors: both
JSNoSuchMethodError
andTypeError
, but also, for example.or
From what I’ve noticed the problem is in Flutter’s preparation of the web platform in the
/web
directory. I triedflutter clean
andflutter pub cache clean
. I even created a new ‘Hello World’ project without external dependencies. All to no effect. The only thing that helped was swapping the contents of thePROJECT_DIR/web/index.html
file:, to the old [deprecated] version: