Flutter:“我的对话框”中的键盘溢出

Shr*_*mal 2 dart flutter flutter-layout

我正在尝试将TextField添加到对话框,但是当出现键盘时,它会产生溢出。

我的对话框图片

对话框图像

当键盘出现时

当键盘出现时

这是我的代码的一部分:

AlertDialog(
    content: new ListView(
      shrinkWrap: true,
  children: <Widget>[
    Text(
      "How Would You Rate Our App?",
      style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),
      textAlign: TextAlign.center,
    )
Run Code Online (Sandbox Code Playgroud)

小智 10

问题出在对话框后面的屏幕上。我遇到了同样的问题,但上述解决方案中没有一个适用于我的代码,所以我使用了以下代码:

resizeToAvoidBottomInset: false,
Run Code Online (Sandbox Code Playgroud)

这一行在“返回脚手架”下我在这个页面上找到了这个解决方案

  • 问题中没有提到“return Scaffold”。您能否详细说明您找到的解决方案,其中包括所有必需的详细信息? (3认同)
  • 这应该是最好的答案 (2认同)

Moh*_*ani 5

您可以简单地使用SingleChildScrollView

 AlertDialog(
        content: SingleChildScrollView(
          scrollDirection: Axis.vertical,
        child: Column(
          children: <Widget>[
            Text(
              "How Would You Rate Our App?",
              style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),
              textAlign: TextAlign.center,
        ),
        ]
    )
    )
)
Run Code Online (Sandbox Code Playgroud)

  • 这似乎不能解决问题。 (4认同)