📜  使用不包含 MediaQuery 的上下文调用 MediaQuery.of(). - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:19.383000             🧑  作者: Mango

代码示例2
void main() => runApp(App());

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Title',
      theme: kThemeData,
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;

    return Container(
      child: ...,
    );
  }
}