flutter 缺少“StatefulWidget.createState”抖动的具体实现

x4shl7ld  于 2023-03-13  发布在  Flutter
关注(0)|答案(1)|浏览(177)

运行应用程序时显示问题
验证码:https://codeshare.io/eV6dyl
在类登录前添加摘要

q43xntqr

q43xntqr1#

试试这个:

class Login extends StatefulWidget {
  const Login({super.key});

  @override
  State<Login> createState() => _LoginState();
}

class _LoginState extends State<Login> {
  @override

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Login"),
      ),
      body: Container(child: Text("Login")),
    );
  }
  }

// Page Main.dart


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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context){
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Login(),
      routes:  {

      },
    );
  }
}

你犯了个错误

_LoginState creatState() => _LoginState();

它应该是:

@override
  State<Login> createState() => _LoginState();

相关问题