0

这是我的 wiget 表单

 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(),
                      ........
                      .........

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

下面是脚手架部分完整代码

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,),
                    ],
                  ),
      ),)
  ]
    )
    ),
    );

请帮助我尝试了很多都没有用,我的代码有什么问题吗

请帮助我尝试了很多都没有用,我的代码有什么问题吗

键盘隐藏了我的 textformfield 飞镖颤振有什么解决方案吗,它尝试了很多都没有用

4

2 回答 2

0

用这个填充包裹表单:

Padding(
  padding: EdgeInsets.only(
    bottom: MediaQuery.of(context).viewInsets.bottom
  ),
)
于 2021-03-19T22:32:37.780 回答
0

将所有内容包装在 SingleChildScrollView 小部件中,您可以在显示键盘时滚动。

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

如果您希望在用户滚动时隐藏键盘,则使用 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(),
  ),
);
于 2021-03-20T22:04:58.983 回答