我的SingleChildScrollView小部件不起作用.....键盘阻止了我的文本输入

时间:2019-09-23 12:43:48

标签: flutter flutter-layout

我需要使我的小部件成为可滚动的小部件。我的singlechildscrollview小部件不起作用。我无法弄清楚。我的键盘阻止了我的文本输入字段。请帮忙。

需要使其进入可滚动页面。 keyboard blocks the input field

如您所见,我能想到的唯一选择是使它成为可滚动页面,以防止键盘阻塞输入字段。

欢迎任何帮助。我对Flutter还是陌生的。谢谢

class RegistrationScreen extends StatefulWidget {
  @override
  _RegistrationScreenState createState() => _RegistrationScreenState();
}

class _RegistrationScreenState extends State<RegistrationScreen> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Material(
        child: Padding(
          padding: const EdgeInsets.all(20.0),
          child: SingleChildScrollView(
            child: Column(
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Padding(
                      padding: const EdgeInsets.only(
                        left: 10.0,
                        top: 20.0,
                      ),
                      child: BackArrow(),
                    ),
                  ],
                ),
                SizedBox(
                  height: 20.0,
                ),
                Row(
                  children: <Widget>[
                    Padding(
                      padding: const EdgeInsets.only(left: 15.0),
                      child: Text(
                        'Sign up',
                        style: TextStyle(
                          fontFamily: "WorkSans-medium",
                          fontSize: 25.0,
                        ),
                      ),
                    ),
                  ],
                ),
                SizedBox(
                  height: 20.0,
                ),
                Column(
                  children: <Widget>[
                    Icon(Icons.supervised_user_circle),
                    SizedBox(
                      height: 10.0,
                    ),
                    Text('Add a profile picture'),
                  ],
                ),
                SizedBox(
                  height: 20.0,
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: InputTextField(
                        paddingLeft: 15.0,
                        paddingRight: 15.0,
                        containerWidth: 380.0,
                        obscureText: false,
                        hintText: 'Username',
                      ),
                    ),
                  ],
                ),
                SizedBox(
                  height: 20.0,
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                        child: InputTextField(
                      paddingLeft: 15.0,
                      paddingRight: 15.0,
                      containerWidth: 380.0,
                      obscureText: true,
                      hintText: 'Password',
                    )),
                  ],
                ),
                SizedBox(
                  height: 20.0,
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                        child: InputTextField(
                      paddingLeft: 15.0,
                      paddingRight: 15.0,
                      containerWidth: 380.0,
                      obscureText: false,
                      hintText: 'City',
                    )),
                  ],
                ),
                SizedBox(
                  height: 20.0,
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                        child: InputTextField(
                      paddingLeft: 15.0,
                      paddingRight: 15.0,
                      containerWidth: 380.0,
                      obscureText: false,
                      hintText: 'Email',
                    )),
                  ],
                ),
                SizedBox(
                  height: 30.0,
                ),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: Padding(
                        padding: const EdgeInsets.only(left: 15.0, right: 15.0),
                        child: RoundedButton(
                          inputText: 'Join the community',
                          width: 310.0,
                          height: 50.0,
                          fontSize: 20.0,
                          textColor: Colors.white,
                          boxColor: Colors.green,
                          onPressed: () {
                            print('Register for an account pressed');
                          },
                        ),
                      ),
                    ),
                  ],
                ),
              ],
            ),
//          decoration: BoxDecoration(
//            color: Colors.white,
//          ),
          ),
        ),
      ),
    );
  }
}

1 个答案:

答案 0 :(得分:0)

好的。因此我发现,如果将我的材料小部件更改为脚手架小部件,一切都会正常。