MediaQueryが使えない!【FlutterError (No MediaQuery widget ancestor found.】

file

Exception has occurred.
FlutterError (No MediaQuery widget ancestor found.
MyApp widgets require a MediaQuery widget ancestor.
The specific widget that could not find a MediaQuery ancestor was:
  MyApp
The ownership chain for the affected widget is: "MyApp ← [root]"
No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of(). This can happen because you have not added a WidgetsApp, CupertinoApp, or MaterialApp widget (those widgets introduce a MediaQuery), or it can happen if the context you use comes from a widget above those widgets.)

原因はこれかも

file

mainrunAppから直接呼んだWidgetMediaQueryを使うと駄目っぽいです。
あとは、runAppから呼んだWidgetMaterialAppがないと駄目っぽい。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です