当前位置:   article > 正文

Flutter 运行报错:MediaQuery.of() called with a context that does not contain a MediaQuery_view.of() was called with a context that does not

view.of() was called with a context that does not contain a view widget.

LoginPage()是写好的用户登录界面,但是想让界面跑起来 需要runApp(),需要再写个MyApp()里面使用MaterialApp()包裹写好的界面
在这里插入图片描述

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter_LoginPlugin',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: LoginPage(),
    );
  }

}

class LoginPage  extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return new _MyAppState();
  }

}


class _MyAppState extends State<LoginPage> {
   //布局页面
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号