title: flutter keep data after reset password
body: <p>i'm work on flutter project . i create a simple function to change password . it's works fine but ( the password change correctly) but i can't keep my actual screen after password changed. i losed all data as you see . My question is How i can keep data in screen after the change of password .</p>
  <p>password screen  :</p>
  <p><a href="https://i.stack.imgur.com/J3PKA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J3PKA.png" alt="enter image description here" /></a></p>
  <p>My screen after the password changed :</p>
  <p><a href="https://i.stack.imgur.com/SWtBT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SWtBT.png" alt="enter image description here" /></a></p>
  <p>and this is my code  :</p>
  <pre><code>  Widget build(BuildContext context) {
      Size size = MediaQuery.of(context).size;
      return SafeArea(
          /* minimum: const EdgeInsets.only(
              top: 20.0, right: 5.0, left: 5.0, bottom: 10.0),*/
          child: Center(
        child: Scaffold(
            resizeToAvoidBottomInset: true,
            backgroundColor: Color(0xFFF6F7F8),
            body: SingleChildScrollView(
                child: Form(
                    key: _formKey,
                    child: FutureBuilder&lt;User&gt;(
                        future: boxApi.getUser(),
                        builder: (context, snapshot) {
                          // ignore: missing_return
                          print(snapshot.data);
                          switch (snapshot.connectionState) {
                            case ConnectionState.none:
                              return Text('no connection');
                            case ConnectionState.active:
                            case ConnectionState.waiting:
                              return Center(
                                child: CircularProgressIndicator(),
                              );
                              break;
                            case ConnectionState.done:
                              if (snapshot.hasError) {
                                return Text('error');
                              } else if (snapshot.hasData) {
                                // String price = snapshot.data['body'].;
                                //  print(&quot;${snapshot.data}&quot;);
                                return Column(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceEvenly,
                                  children: [
                                    Container(
                                      padding: EdgeInsets.only(top: 16),
                                      width: MediaQuery.of(context).size.width,
                                      height:
                                          MediaQuery.of(context).size.height / 4,
                                      decoration: BoxDecoration(
                                          boxShadow: [
                                            BoxShadow(
                                                color: Colors.white60,
                                                blurRadius: 15.0,
                                                offset: Offset(0.0, 0.75))
                                          ],
                                          gradient: LinearGradient(
                                            begin: Alignment(0.5, 0.85),
                                            end: Alignment(0.48, -1.08),
                                            colors: [
                                              const Color(0xFF0B0C3A),
                                              const Color(0xFF010611),
                                            ],
                                            stops: [
                                              0.0,
                                              0.5,
                                            ],
                                          ),
                                          //color: blue,
                                          borderRadius: BorderRadius.only(
                                              bottomRight: Radius.circular(32),
                                              bottomLeft: Radius.circular(32))),
                                      child: Column(
                                        children: [
                                          Row(
                                            children: [
                                              SizedBox(
                                                width: 30,
                                              ),
                                              Column(
                                                  crossAxisAlignment:
                                                      CrossAxisAlignment.start,
                                                  children: [
                                                    Text(
                                                      &quot;${snapshot.data.name}&quot;,
                                                      style: TextStyle(
                                                          color: Colors.white,
                                                          fontSize: 25,
                                                          fontWeight:
                                                              FontWeight.bold),
                                                    ),
                                                    SizedBox(
                                                      height: 10,
                                                    ),
                                                    Text(
                                                      &quot;${snapshot.data.phone}&quot;,
                                                      style: TextStyle(
                                                        color: Colors.white60,
                                                        fontSize: 18,
                                                        //fontWeight: FontWeight.w300
                                                      ),
                                                    ),
                                                  ])
                                            ],
                                          ),
                                          Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.end,
                                            children: [
                                              Container(
                                                  margin: EdgeInsets.symmetric(
                                                      vertical: 10),
                                                  width: size.width * 0.4,
                                                  child: ElevatedButton(
                                                    /*onPressed: () =&gt; [
                                                      modifyUserName(),
                                                      //  modifyUserEmail(),
                                                      //   modifyUserAdress()
                                                    ],*/
                                                    onPressed: () {
                                                      editUserProfile();
                                                      //   modifyUserEmail();
                                                    },
                                                    child: Text('Enregistrer'),
                                                    style:
                                                        ElevatedButton.styleFrom(
                                                      primary: Colors.transparent,
                                                      shape:
                                                          RoundedRectangleBorder(
                                                              borderRadius:
                                                                  BorderRadius
                                                                      .circular(
                                                                          20),
                                                              side: BorderSide(
                                                                  color: Colors
                                                                      .white)),
                                                    ),
                                                  )),
                                              SizedBox(
                                                width: 20,
                                              ),
                                            ],
                                          )
                                        ],
                                      ),
                                    ),
                                    Container(
                                      height: MediaQuery.of(context).size.height /
                                          1.5,
                                      // padding: EdgeInsets.only(
                                      //   top: 32,
                                      // ),
                                      child: Column(
                                        mainAxisAlignment:
                                            MainAxisAlignment.start,
                                        children: [
                                          Column(
                                            mainAxisAlignment:
                                                MainAxisAlignment.start,
                                            children: [
                                              Container(
                                                width: size.width * 0.94,
                                                child: Column(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment.start,
                                                  children: [
                                                    Container(
                                                      padding: EdgeInsets.only(
                                                          left: 10,
                                                          right: 10,
                                                          bottom: 20,
                                                          top: 20),
                                                      child: Column(
                                                        mainAxisAlignment:
                                                            MainAxisAlignment
                                                                .start,
                                                        crossAxisAlignment:
                                                            CrossAxisAlignment
                                                                .start,
                                                        children: [
                                                          Row(
                                                            mainAxisAlignment:
                                                                MainAxisAlignment
                                                                    .spaceBetween,
                                                            children: [
                                                              Text(
                                                                'Votre nom :',
                                                                style: TextStyle(
                                                                    color: Color(
                                                                        0xFF4053FCF),
                                                                    fontSize: 16,
                                                                    fontWeight:
                                                                        FontWeight
                                                                            .w600),
                                                              ),
                                                              IconButton(
                                                                  icon: Icon(
                                                                    CommunityMaterialIcons
                                                                        .pencil,
                                                                    color: Colors
                                                                        .grey,
                                                                  ),
                                                                  onPressed: () {
                                                                    myFocusNode
                                                                        .requestFocus();
                                                                    //    setState(() {
                                                                    enableup =
                                                                        true;
                                                                    //    });
                                                                  })
                                                            ],
                                                          ),
                                                          TextFormField(
                                                            controller:
                                                                _nameController,
                                                            enabled: enableup,
                                                            focusNode:
                                                                myFocusNode,
                                                            enableInteractiveSelection:
                                                                false,
                                                            keyboardType:
                                                                TextInputType
                                                                    .text,
                                                            decoration: InputDecoration(
                                                                hintText:
                                                                    &quot;${snapshot.data.name}&quot;,
                                                                hintStyle: TextStyle(
                                                                    color: Colors
                                                                        .grey,
                                                                    fontSize:
                                                                        14.0)),
                                                          ),
                                                          SizedBox(
                                                            height: 15,
                                                          ),
                                                          
                                                        
                                                         
                                                          Row(
                                                            mainAxisAlignment:
                                                                MainAxisAlignment
                                                                    .spaceBetween,
                                                            children: [
                                                              Text(
                                                                'Mot de passe :',
                                                                style: TextStyle(
                                                                    color: Color(
                                                                        0xFF4053FCF),
                                                                    fontSize: 16,
                                                                    fontWeight:
                                                                        FontWeight
                                                                            .w600),
                                                              ),
                                                              IconButton(
                                                                  icon: Icon(
                                                                    CommunityMaterialIcons
                                                                        .pencil,
                                                                    color: Colors
                                                                        .grey,
                                                                  ),
                                                                  onPressed:
                                                                 () async {
                                                                    await cahngePwd(
                                                                        context);
                                                                  })
                                                            ],
                                                          ),
                                                          TextFormField(
                                                            enabled: enablepwd,
                                                            focusNode:
                                                                passwordNode,
                                                            enableInteractiveSelection:
                                                                false,
                                                            obscureText: true,
                                                            keyboardType:
                                                                TextInputType
                                                                    .text,
                                                            decoration: InputDecoration(
                                                                hintText:
                                                                    &quot;*************&quot;,
                                                                hintStyle: TextStyle(
                                                                    color: Colors
                                                                        .grey,
                                                                    fontSize:
                                                                        14.0)),
                                               
                              } else {
                                return Text('No Data');
                              }
                              break;
                            default:
                              return Container();
                              break;
                          }
                        }
  
    }
   void changePassword() async {
      setState(() {});
      String old_password = _oldController.text;
      String new_password = _newController.text;
      String confirm_password = _confirmController.text;
  
      try {
        await userApi.changePassword(
            old_password, new_password, confirm_password);
      } catch (err) {
        print(err.toString());
        // Todo: add Snackbar
      }
  
      Navigator.of(context).pop(); // Dismiss alert dialog
      setState(() {});
  </code></pre>