代码之家  ›  专栏  ›  技术社区  ›  Jaswant Singh

在iOS中推送路线时抖动黑屏

  •  1
  • Jaswant Singh  · 技术社区  · 8 年前

    我在启动屏幕上,它工作正常,4秒钟后,我跳转到登录屏幕,而不是显示登录屏幕,它显示了一个没有任何内容的黑屏。 我跳转到登录屏幕

    Navigator.of(context).push(MaterialPageRoute(builder: (context) => Login()));
    

    谁能告诉我哪里出了问题?我尝试过各种方法,比如在两条路由(Splash和login)上使用WillPopScope()小部件,更改路由名称,

    它在安卓系统上运行得很好,但在iOS上却不行,这有点奇怪。 我登录页面的代码是

     @override
     Widget build(BuildContext context) {
     this._context = context;
     return new GestureDetector(
       onTap: () {
        _dismissKeyboard(_context);
       },
       child: SingleChildScrollView(child: Scaffold(
          key: scaffoldState,
          resizeToAvoidBottomPadding: false,
          body: !isLoading
              ? new Stack(
                  children: <Widget>[
                    Container(
                        child: new Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Hero(
                            tag: "pricelogo",
                            child: new Container(
                              child: Image.asset('assets/logo.png'),
                              height: 100.0,
                              width: 100.0,
                            )),
                        Container(
                          height: 80.0,
                        ),
                        Container(
                          decoration:
                              BoxDecoration(color: Colors.lightBlue[50]),
                          margin: EdgeInsets.only(left: 40.0, right: 40.0),
                          padding: EdgeInsets.only(
                              left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
                          child: TextField(
                            controller: emailController,
                            decoration: InputDecoration(
                              icon: new Container(
                                child: new ImageIcon(
                                  new AssetImage("assets/user.png"),
                                  color: Colors.blue,
                                ),
                              ),
                              hintText: 'Email',
                              hintStyle: new TextStyle(fontSize: 16.0),
                              border: InputBorder.none,
                            ),
                            style: new TextStyle(
                                color: Colors.black, fontSize: 16.0),
                          ),
                        ),
                        Container(
                            decoration:
                                BoxDecoration(color: Colors.lightBlue[50]),
                            margin: EdgeInsets.only(
                                left: 40.0, right: 40.0, top: 20.0),
                            padding: EdgeInsets.only(
                                left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
                            child: new TextField(
                              controller: passwordController,
                              obscureText: true,
                              decoration: InputDecoration(
                                icon: new Container(
                                    child: new ImageIcon(
                                  new AssetImage("assets/password.png"),
                                  color: Colors.blue,
                                )),
                                hintText: 'Password',
                                hintStyle: new TextStyle(fontSize: 16.0),
                                border: InputBorder.none,
                              ),
                              style: new TextStyle(
                                  color: Colors.black, fontSize: 16.0),
                            )),
                        Padding(
                          padding: EdgeInsets.symmetric(vertical: 45.0),
                          child: Material(
                            borderRadius: BorderRadius.circular(30.0),
                            shadowColor: Colors.blue,
                            elevation: 5.0,
                            child: MaterialButton(
                              minWidth: 300.0,
                              height: 50.0,
                              onPressed: () {
                                if (areFieldsValid()) {
                                  if (_connectionStatus ==
                                          ConnectivityResult.wifi ||
                                      _connectionStatus ==
                                          ConnectivityResult.mobile) {
                                    _makeLoginApiCall();
                                  } else {
                                    scaffoldState.currentState.showSnackBar(
                                        new SnackBar(
                                            content: new Text(
                                                "Please check your internet connection and try again")));
                                  }
                                }
                              },
                              color: Colors.blue,
                              child: Text('Login',
                                  style: TextStyle(color: Colors.white)),
                            ),
                          ),
                        ),
                        Container(
                          margin: EdgeInsets.only(bottom: 20.0),
                          child: Text("or sign in with:"),
                        ),
                        Center(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                              isFacebookSignInEnabled
                                  ? Image(
                                      image: AssetImage("assets/facebook.png"),
                                      height: 50.0,
                                      width: 50.0,
                                    )
                                  : Container(),
                              Container(
                                width: isGoogleSignInEnabled ? 40.0 : 0.0,
                              ),
                              isGoogleSignInEnabled
                                  ? Image(
                                      image: AssetImage("assets/google.png"),
                                      height: 50.0,
                                      width: 50.0,
                                    )
                                  : Container(),
                            ],
                          ),
                        ),
                      ],
                    )),
                    Container(
                        margin: EdgeInsets.only(left: 15.0, bottom: 5.0),
                        alignment: Alignment.bottomLeft,
                        child: Row(
                          children: <Widget>[
                            Text(
                              "Don't have an account?",
                              style: TextStyle(fontSize: 14.0),
                            ),
                            GestureDetector(
                              onTap: () {
                                Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                        builder: (context) => Signup()));
                              },
                              child: Text(
                                "  Signup",
                                style: TextStyle(
                                    color: Colors.blueAccent,
                                    decoration: TextDecoration.underline,
                                    fontSize: 16.0),
                              ),
                            )
                          ],
                        )),
                    GestureDetector(
                      onTap: () {
                        Navigator.of(context).push(MaterialPageRoute(
                            builder: (context) => ForgotPassword()));
                      },
                      child: Container(
                        margin: EdgeInsets.only(right: 15.0, bottom: 5.0),
                        alignment: Alignment.bottomRight,
                        child: Text(
                          "Forgot Password?",
                          style: TextStyle(fontSize: 14.0),
                        ),
                      ),
                    )
                  ],
                )
              : Container(
                  alignment: Alignment.center,
                  child: CircularProgressIndicator(
                    strokeWidth: 4.0,
                    backgroundColor: Colors.blue,
                  ),
                )),
          ),
        );
      }
    
    0 回复  |  直到 8 年前