原来的代码中有:
//尺寸适配方案
widgetsBinding
..attachRootWidget(MultiProvider(providers: providers, child: MyApp()))
..scheduleWarmUpFrame();
用来做尺寸适配,但是升级后显示
No MediaQuery ancestor could be found starting from the context that was pas......
所以去掉了这个尺寸适配方案,使用screenutil来做适配。
原来
//尺寸适配方案
的代码去掉,换成:
runApp(MultiProvider(providers: providers, child: MyApp()));
后续每个页面做一下尺寸适配就可以了。
至于为什么会报错,应该是原来的代码中widgetsBinding对于做适配有问题,需要更改这个widgetsBinding适配,继续用widgetsBinding做适配太多东西需要处理,所以放弃了。