0

我正在尝试构建一个包含一些图标(左侧两个,右侧另外两个)的 BottomAppBar,我想在它们之间添加一个文本输入字段,但无论我尝试什么,它都不起作用.

代码编译得很好,但是当打开使用这个小部件的页面时,现在会出现以下错误:

RenderBox 未布置:RenderRepaintBoundary#bcb66 NEEDS-LAYOUT NEEDS-PAINT

这是我的代码:

Widget _buildBottomNavBar(){
  return BottomAppBar(
    child: Row(
      children:
      [
        IconButton(icon: Icon(Icons.attach_file_rounded), onPressed: () {}),
        IconButton(icon: Icon(Icons.emoji_emotions_outlined), onPressed: () {}),
        TextFormField(
          decoration: InputDecoration(labelText: 'Message'),
        ),
        IconButton(icon: Icon(Icons.play_arrow_rounded), onPressed: () {}),
        IconButton(icon: Icon(Icons.undo_rounded), onPressed: () {}),
      ],
    ),
  );
}

这看起来很简单,但我尝试了多种方法(包括将 TextFormField 包装在 Expanded 小部件中),但似乎没有任何效果。非常感谢任何有用的想法。蒂亚

更新(这里是固定代码,忘了添加孩子:)

Widget _buildBottomNavBar(){
  return BottomAppBar(
    child: Row(
      children:
      [
        IconButton(icon: Icon(Icons.attach_file_rounded), onPressed: () {}),
        IconButton(icon: Icon(Icons.emoji_emotions_outlined), onPressed: () {}),
        Expanded(child:
        TextFormField(
          decoration: InputDecoration(labelText: 'Message'),
        )),
        IconButton(icon: Icon(Icons.play_arrow_rounded), onPressed: () {}),
        IconButton(icon: Icon(Icons.undo_rounded), onPressed: () {}),
      ],
    ),
  );
}

顺便说一句,请原谅我蹩脚的缩进。

4

0 回答 0