Как расположить элементы внутри ListView? - PullRequest
1 голос
/ 08 апреля 2019

Доброе утро.Я сделал этот экран , и он работает как шарм на высоких разрешениях.Проблема в том, что я хочу поддерживать более низкие разрешения, такие как Nexus 4 (768x1280).

Поэтому, когда я запускаю это на эмуляторе (размер Nexus 4) и касаюсь полей ввода, клавиатура либо: блокирует входы, либо перемещает две кнопки внизу и накладывает их на что-то другое.

Итак, чтобы решить эту проблему, я обернул весь макет в ListView (), но теперь нижние кнопки, которые обернуты в Row (), просто не останутся в нижней части.

Это мой код без ListView, работающий в высоком разрешении, но не в низком:

return Form(
  Stack(
    Center(
      Column(
        ...
      ),
    ),
    Align(
      alignment: Alignment.bottomCenter,
      child: Row(
        ...
      ),
    ),
  ),
);

Это , как это выглядит с resizeToAvoidBottomPadding: false И это так выглядит при значении true

Спасибо всем.

Ответы [ 2 ]

1 голос
/ 08 апреля 2019

Вы пытались использовать SingleChildScrollView?

Это виджет, позволяющий странице изменять размеры по высоте и прокручивать ее, для просмотра списка, который не является тем, для чего предназначен просмотр списка, вы должны добавить просмотр списка, когда получите неизвестный объем данных,

Обычно мы не используем его, чтобы просто настроить вид.


хорошо, поэтому я отредактировал код, как здесь, и я могу нормально прокручиваться после того, как клавиатура всплывает, и вид хороший, и я могу нажать на кнопку, как обычно, попробуйте.

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

       ]

       )

       ,

    // )
    );
  }
0 голосов
/ 08 апреля 2019

В вашем Scaffold вы можете попробовать это.

Scaffold(
  resizeToAvoidBottomInset: false,
  ...
);
...