keypad hides my textformfield dart flutter is there any solution, it tried a lot nothing worked

Viewed 160

here is my the wiget with form

 Widget verticalList = new ListView(
        shrinkWrap: true,
        children: [
          Container(
            color:Colors.white,
            width: MediaQuery.of(context).size.width,
            child:  Form(
              key: _formKey,
              child:Column(
                //  shrinkWrap: true,
                mainAxisSize:MainAxisSize.min,
                children: [
                      textformField(),
                      textformField(),
                      textformField(),
                      textformField(),
                      textformField(),
                      ........
                      .........

                ],
              ),
            ),
          ),
        ],
    );

here below scaffold part full code

return Scaffold(
      resizeToAvoidBottomInset: true,
      body: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.center,
              stops: [0.0,1,1.2],
              colors: <Color>[
                Color(0xff19879a),
                Color(0xff000e11),
                Color(0xff000e02),
              ],
            ),
          ),
          child: Column(
              children:[
                Container(
                  height: 160,
                  width: MediaQuery.of(context).size.width,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Expanded(flex:3,
                        child: Container(
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.end,
                            children: [
                              FittedBox(child: Text("Firm Details",style: GoogleFonts.lato(color: Color(0xfffbfbfb),fontSize: 1.8*SizeConfig.textMultiplier))),
                              SizedBox(height: 0.5*SizeConfig.heightMultiplier,),
                              Padding(
                                padding: const EdgeInsets.only(left:30.0),
                                child: Text(
                                 "Please select the category that best describes your business model.",
                                  textAlign: TextAlign.right,
                                  style: GoogleFonts.lato(
                                      color: Color(0xffb3fbfbfb),
                                      fontSize: 1.5*SizeConfig.textMultiplier),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                      Expanded(
                        flex: 2,
                        child: Container(
                          width: 10.0*SizeConfig.widthMultiplier,
                          height: 10.0*SizeConfig.heightMultiplier,
                          child: Image.asset(
                            "assets/images/firmDetail.png",
                            width: 10.0*SizeConfig.widthMultiplier,
                            height: 10.0*SizeConfig.heightMultiplier,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
                Expanded(
                  child: Container(
                  decoration: BoxDecoration(
                      color: Colors.white,
                      border: Border.all(
                        color: Colors.white,
                      ),
                      borderRadius: BorderRadius.only(topLeft:Radius.circular(30),topRight: Radius.circular(30))
                  ),
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Expanded(flex:1,child: horizontalList1),
                      Expanded(flex:5,child:verticalList,),
                    ],
                  ),
      ),)
  ]
    )
    ),
    );

please help i tried a lot nothing worked , is there any problem with my code

please help i tried a lot nothing worked , is there any problem with my code

keypad hides my textformfield dart flutter is there any solution, it tried a lot nothing worked

2 Answers

Wrap everything in a SingleChildScrollView widget and you can scroll when the keyboard is displayed.

Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    title: Text('Your Title'),
  ),
  body: SingleChildScrollView(
    child:  _buildPage(),
  ),
);}

If you want the keyboard to hide when the user scrolls then wrap it all with NotificationListener<ScrollUpdateNotification>.

body: NotificationListener<ScrollUpdateNotification>(
  onNotification: (notification) {
      // dismiss keyboard on scroll if user initiated the scroll (ie dragDetails != null)
      if (notification.dragDetails != null) {
        FocusScope.of(context).unfocus();
      }
      return true;
  },
  child: SingleChildScrollView(
    child: _buildPage(),
  ),
);

Wrap the form with this padding:

Padding(
  padding: EdgeInsets.only(
    bottom: MediaQuery.of(context).viewInsets.bottom
  ),
)
Related