Flutter:设置appbar自定义标题高度

Flutter: set appbar custom title height

我在应用栏中添加了这样的搜索小部件:

return Scaffold(
  appBar: AppBar(
    title: Container(
      margin: EdgeInsets.only(top: 30),
      decoration: BoxDecoration(
        color: Color.fromARGB(50, 255, 255, 255),
        borderRadius: BorderRadius.all(Radius.circular(20)),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Expanded(
            child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 5.0),
              child: TextFormField(...
                    )),
              ),
            ),
          )
        ],
      ),
    ),
    bottom: PreferredSize(
      preferredSize: Size.fromHeight(100.0),
      child: TabBar(...

我添加了前 30 个边距,但搜索部分被裁剪了:

如何增加应用栏中的默认 title 大小

您可以使用 flexibleSpace 代替标题。

return Scaffold(
  appBar: AppBar(
    flexibleSpace: Container(....

flexibleSpace 工作正常,但另一种方法是使用 PreferredSize.

Scaffold(
  appBar: PreferredSize(
    preferredSize: Size.fromHeight(100.0),
    child:AppBar(
      title:Text("title"),
    )
  ),
  body:...
 )