应用程序启动后如何启动登录和启动屏幕页面

问题描述 投票:1回答:1

我正在为某个应用程序开发登录页面和启动画面,如何将这些路径设置为仅启动一次?

Stack(
          fit: StackFit.loose,
          children: <Widget>[
            Image(
              image: AssetImage('images/home.png'),    
              fit: BoxFit.cover,
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height,
            ),
            Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  // SizedBox(height: 20.0),
                  //height  was 60
                  Column(
                    children: <Widget>[
                      SizedBox(
                        height: 30.0,
                      ),
                      Text(
                        "SMART HYDROPONICS",
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 22.0,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      SizedBox(
                        height: 30.0,
                      ),
                      CircleAvatar(
                          backgroundColor: Colors.white,
                          radius: 90.0,
                          child: Container(
                            alignment: Alignment.center,
                            child: CircleAvatar(
                              backgroundColor: Colors.green,
                              child: Text(
                                'REGISTER',
                                style: TextStyle(
                                    fontWeight: FontWeight.bold,
                                    color: Colors.white),
                              ),
                              radius: 70.0,
                            ),
                          )),
                    ],
                  ),
                  SizedBox(height: 20.0),
                  Form(
                    key: _key,
                    autovalidate: _autovalidate,
                    child: Column(children: <Widget>[
                      TextFormField(
                        decoration: InputDecoration(
                            hintText: "Enter Name",
                            border: InputBorder.none,
                            hintStyle: TextStyle(
                                color: Colors.white,
                                wordSpacing: 20.0,
                                fontWeight: FontWeight.normal,
                                fontSize: 18.0),
                            icon: Icon(
                              Icons.nature_people,
                              size: 30.0,
                              color: Colors.black,
                            )),
                        maxLength: 25,
                        keyboardType: TextInputType.text,
                        obscureText: false,
                        textAlign: TextAlign.justify,
                        onSaved: (val) {
                          _name = val;
                        },
                        validator: _myName,
                      ),
                      SizedBox(
                        height: 20.0,
                      ),
                      SizedBox(height: 40.0),
                      TextFormField(
                        textCapitalization: TextCapitalization.characters,
                        decoration: InputDecoration(
                            hintText: "Enter Number",
                            border: InputBorder.none,
                            // contentPadding: EdgeInsets.all(0.0),
                            hintStyle: TextStyle(
                                color: Colors.white,
                                wordSpacing: 20.0,
                                fontWeight: FontWeight.normal,
                                fontSize: 18.0),
                            icon: Icon(
                              Icons.phone,
                              size: 30.0,
                              color: Colors.black,
                            )),
                        maxLength: 10,
                        maxLines: 1,
                        keyboardType: TextInputType.phone,
                        obscureText: false,
                        textAlign: TextAlign.justify,
                        onSaved: (val) {
                          _number = val;
                        },
                        validator: _myNumber,
                      ),
                      SizedBox(
                        height: 50.0,
                      ),
                      TextFormField(
                        textCapitalization: TextCapitalization.characters,
                        decoration: InputDecoration(
                            hintText: "Product ID",
                            border: InputBorder.none,
                            // contentPadding: EdgeInsets.all(0.0),
                            hintStyle: TextStyle(
                                color: Colors.white,
                                wordSpacing: 20.0,
                                fontWeight: FontWeight.normal,
                                fontSize: 18.0),
                            icon: Icon(
                              Icons.settings_brightness,
                              size: 30.0,
                              color: Colors.black,
                            )),
                        maxLength: 10,
                        maxLines: 1,
                        keyboardType: TextInputType.phone,
                        obscureText: false,
                        textAlign: TextAlign.justify,
                        onSaved: (val) {
                          _number = val;
                        },
                        validator: _productId,
                      ),
                      // SizedBox(height: MediaQuery.of(context).size.height/990000 ),

                      RaisedButton(
                          onPressed: _sendToServer,
                          color: Colors.greenAccent,
                          child: Text(
                            "Finish",
                            style: TextStyle(
                              color: Colors.white,
                            ),
                          )),

                    ]),
                  ),
                ]),
          ],
        )
dart flutter flutter-layout dart-pub flutter-dependencies
1个回答
0
投票

你需要通过the shared_preferences plugin或其他一些像sqlite或平面文件这样的本地持久存储来保持持久状态(比如登录标记或标记标记为已接收/接受的标记)。

© www.soinside.com 2019 - 2024. All rights reserved.