且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ListView中放置元素?

更新时间:2022-02-04 09:40:29

您尝试使用SingleChildScrollView吗?

Did you try to use SingleChildScrollView ?

这是一个小部件,用于使页面能够调整高度并滚动, listview不是listview的功能,当您获得未知数量的数据时,应该添加listview。

It is a widget for making the page able to resize the height and as well scrolling , for the listview thats not what is the listview for , you should add listview when you get an unknown amount of data,

我们通常不使用它来调整视图。

We don't normally use it to just adjust the view.

确定,所以我在这里编辑了代码,键盘弹出后,视图可以正常滚动

ok so i edited the code as in here and i can scroll normally after the keyboard pop up and the view is good and i can click on the button normally try it.

  Widget formWidget(){
    return new Scaffold(
      // appBar: AppBar(
      //   // Here we take the value from the MyHomePage object that was created by
      //   // the App.build method, and use it to set our appbar title.
      //   title: Text(widget.title),
      // ),
      body:Column( 
          children: <Widget> [ 
          Expanded(
       child:SingleChildScrollView(
        child: Form(

          child: 
          // Stack(
          //   children: <Widget>[
              // Center(
                // child: SingleChildScrollView(
                  // child: 
                  Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisSize: MainAxisSize.max,

                    children: [
                      Padding(
                        padding: (MediaQuery.of(context).size.height) > 600
                            ? const EdgeInsets.only(top: 0.0)
                            : const EdgeInsets.only(top: 30.0),
                        child: Image(
                          image: AssetImage('assets/favIcon.png'),
                          width: 88.0,
                          height: 88.0,
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.fromLTRB(0, 28.0, 0, 12.0),
                        child: Text(
                          'Delegados',
                          style: TextStyle(
                            fontFamily: 'Archia',
                            fontSize: 32.0,
                          ),
                        ),
                      ),
                      Text(
                        'Introduce tus datos de acceso aquí.',
                        style: TextStyle(
                          color: Color(0xff83868F),
                          fontFamily: 'Brutal',
                          fontSize: 14.0,
                        ),
                      ),
                      Padding(
                        padding:
                        const EdgeInsets.fromLTRB(16.0, 26.0, 16.0, 12.0),
                        child: TextFormField(
                          decoration: InputDecoration(
                            labelText: 'Correo',
                            filled: true,
                            fillColor: Color(0xffF0F1F5),
                            border: OutlineInputBorder(
                              borderRadius: BorderRadius.circular(8.0),
                              borderSide: BorderSide(
                                width: 0,
                                style: BorderStyle.none,
                              ),
                            ),
                          ),
                          style: TextStyle(
                            fontFamily: 'Brutal',
                            color: Color(0xff1A1B1F),
                          ),
                           controller: TextEditingController() ,

                            textInputAction: TextInputAction.next,
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 12.0),
                        child: TextFormField(
                          keyboardType: TextInputType.emailAddress,
                          decoration: InputDecoration(
                            labelText: 'Contraseña',
                            filled: true,
                            fillColor: Color(0xffF0F1F5),
                            suffixIcon: Icon(Icons.remove_red_eye),
                            border: OutlineInputBorder(
                              borderRadius: BorderRadius.circular(8.0),
                              borderSide: BorderSide(
                                width: 0,
                                style: BorderStyle.none,
                              ),
                            ),
                          ),
                          style: TextStyle(
                            fontFamily: 'Brutal',
                            color: Color(0xff1A1B1F),
                          ),
                           controller: TextEditingController() ,
                           //focusNode:FocusNode(),

                          obscureText: true,
                        ),
                      ),
                      Align(
                        alignment: Alignment.centerRight,
                        child: Padding(
                          padding: const EdgeInsets.fromLTRB(0, 0, 0, 26.0),
                          child: CupertinoButton(
                            onPressed: () {},
                            child: Text(
                              'Olvidé mi Contraseña',
                              style: TextStyle(
                                color: Color(0xff565A66),
                                fontFamily: 'Brutal',
                                fontSize: 14.0,
                              ),
                            ),
                          ),
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 0),
                        child: ButtonTheme(
                          minWidth: double.infinity,
                          child: InkWell(
                            // onTap: state is! LoginLoading
                            //     ? _onLoginButtonPressed
                            //     : null,
                            child: Container(
                              height: 48.0,
                              width: 500.0,
                              decoration: BoxDecoration(
                                color: Color(0xff00CC36),
                                borderRadius: BorderRadius.circular(8.0),
                              ),
                              child: Align(
                                  alignment: Alignment.center,
                                  child: Container(
                                    child: 
                                    // state is LoginLoading
                                    //     ? CircularProgressIndicator():
                                         Text(
                                      'INGRESAR AHORA    ›',
                                      style: TextStyle(
                                        color: Colors.white,
                                        fontFamily: 'Brutal',
                                        fontSize: 14.0,
                                      ),
                                    ),
                                  )),
                            ),
                          ),
                        ),
                      ),

                    ],
                  ),
                // ),
              )
              ,
              // aqui va <<<<<<<<<<<<
            // ],
          // ),
             )  
       ),
       Align(
                        alignment: Alignment.bottomCenter,

                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            CupertinoButton(
                              onPressed: () {},
                              child: Text(
                                '¿No tienes cuenta?',
                                style: TextStyle(
                                  color: Color(0xff83868F),
                                  fontFamily: 'Brutal',
                                  fontSize: 14.0,
                                ),
                              ),
                            ),
                            InkWell(
                              onTap: null,
                              child: Container(
                                height: 32.0,
                                width: 112.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(6.0),
                                  border: Border.all(
                                    color: Color(0xffD7D9E0),
                                    width: 1.0,
                                  ),
                                ),
                                child: Align(
                                  alignment: Alignment.center,
                                  child: Text(
                                    'CONTACTANOS',
                                    style: TextStyle(
                                        color: Color(0xff565A66),
                                        fontFamily: 'Brutal',
                                        fontSize: 11.0),
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),

       ]

       )

       ,

    // )
    );
  }