当前位置:   article > 正文

flutter: 弹出键盘后内容溢出屏幕_flutter textinputfield 弹出键盘导致破表

flutter textinputfield 弹出键盘导致破表

https://dev.to/rubensdemelo/flutter-forms-improving-uiux-with-singlechildscrollview-36gd
使用SingleChildScrollView

Widget build(BuildContext context) {
    return Center (
      child: SingleChildScrollView(
          child: Center(
            child: Card(
              margin: const EdgeInsets.all(12.0),
              // 可以设置半径为12的圆角
              shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12.0))),
              elevation: 15.0,  //设置阴影
              child: Column(
                mainAxisSize: MainAxisSize.min, // 主轴上最小,不会有多余空间
                children: <Widget>[
                  ClipRRect(
                      borderRadius: BorderRadius.circular(4),
                      child: Image.asset(
                        'assets/img/login.png',
                      )
                  ),
                  Container(
                      padding: const EdgeInsets.all(8.0),
                      child: Column(
                          children: <Widget>[
                            TextField(
                              obscureText: false, // 是否为密码
                              decoration: InputDecoration(
                                labelText: 'Account',
                                enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
                              ),
                            ),
                            TextField(
                              maxLength: 10,//最大长度,设置此项会让TextField右下角有一个输入数量的统计字符串
                              obscureText: true,
                              decoration: InputDecoration(
                                labelText: 'Password',
                                enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
                              ),
                            ),
                          ]
                      )
                  ),
                  ButtonTheme.bar(
                    // make buttons use the appropriate styles for cards
                    child: ButtonBar(
                      children: <Widget>[
                        FlatButton(
                          child: const Text('LOGIN'),
                          onPressed: () {
                            print("登入失败");
                          },
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          )
      ),
    );
  }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号