【问题标题】:Render overflow when TextField is in focus当 TextField 处于焦点时呈现溢出
【发布时间】:2018-10-21 17:15:38
【问题描述】:

我有 Column 里面有 TextField 和 Flexible 。灵活的由显示英雄角色列表的 ListView 组成。 当我开始关注 TextField 时,显示屏会显示 x 个像素的渲染溢出。怎么做才能避免这种情况?

  @override
  Widget build(BuildContext context) {
    return new Stack(
      children: <Widget>[
        new Padding(
          padding: new EdgeInsets.all(10.0),
          child: new TextField(
            keyboardType: TextInputType.text,
            controller: tc,
          ),
        ),
        new Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            new Container(
              margin: new EdgeInsets.only(top: 60.0),
              height: MediaQuery.of(context).size.height * 0.67,
              child: checkList(context, characterDataWrapper), //MY LISTVIEW
            ),
            new Flexible(
              fit: FlexFit.loose,
              child: new Container(),
            ),
            new Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisSize: MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.end,
                children: <Widget>[
                  new RaisedButton(
                    onPressed: getData,
                    color: Colors.red,
                    textColor: Colors.white,
                    child: new Text("Click"),
                  ),
                ]),
          ],
        )
      ],
    );
  }

【问题讨论】:

  • 请在您的问题中添加允许重现的代码以及出现错误的手机屏幕截图
  • 请提供您的代码并发布您需要展示的图片。
  • 我无法上传图片,因为我的声誉很低。 ??????
  • @GünterZöchbauer 我已添加代码

标签: android dart flutter flutter-layout


【解决方案1】:

我认为这个问题在

new Container(
              margin: new EdgeInsets.only(top: 60.0),
              height: MediaQuery.of(context).size.height * 0.67,
              child: checkList(context, characterDataWrapper), //MY LISTVIEW
            ),

请提供您的代码或任何截图。

我认为您在顶部有一个文本字段, 中间有一个 Listview,底部有一个按钮。

那你可以这样试试……

@override
  Widget build(BuildContext context) {
    return new Column(
      children: <Widget>[
        new TextField(
          decoration: new InputDecoration(hintText: "I am the TextField"),
        ),
        new Flexible(
            flex: 1,
            child: new ListView(
              children: <Widget>[
                new ListTile(
                  title: new Text("Some Text"),
                ),
                new ListTile(
                  title: new Text("Some Text"),
                ),
                new ListTile(
                  title: new Text("Some Text"),
                ),
                new ListTile(
                  title: new Text("Some Text"),
                ),
                new ListTile(
                  title: new Text("Some Text"),
                ),
                new ListTile(
                  title: new Text("Some Text"),
                ),
                new ListTile(
                  title: new Text("Some Text"),
                ),
                new ListTile(
                  title: new Text("Some Text"),
                ),
              ],
            )),
        new RaisedButton(onPressed: () {})
      ],
    );
  }

我想这会对你有所帮助。

【讨论】:

  • 成功了。向你致敬。!我使用 Expanded 而不是 Flexible 但它有效。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多