更新:
这个问题基本上解决了。
有两种情况会发生这个问题。
一,widget外面不包含材料设计库的widget,材料设计库里面的widget有MediaQuery
二,层次性的会处于上面的东西会报这种错,比如说floatingactionbutton就是在其他层级上面的,在里面调用MediaQuery.of(context)也会报这个错
提示错误:
No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of().
This can happen because you do not have a WidgetsApp or MaterialApp widget (those widgets introduce
a MediaQuery), or it can happen if the context you use comes from a widget above those widgets.
上面的提示基本上已经解决了
----------------------------------------------------------------------------------------------------
MediaQuery.of(context)
这个函数经常报错,原因不清楚,flutter现在的资料实在是太少了
我这个报错的情况是将其放在了statefulwidget里面
所以,一定要将根布局换成一个statelesswidget里面
但是非常蛋疼,放在statelesswidget里面后textfield的状态又没法保存