代码之家  ›  专栏  ›  技术社区  ›  Cyrus the Great

颤振:设置appbar自定义标题高度

  •  0
  • Cyrus the Great  · 技术社区  · 6 年前

    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(...
    

    enter image description here

    如何增加默认值 title 在appbar?

    2 回复  |  直到 6 年前
        1
  •  1
  •   Lunedor    6 年前

    您可以使用flexibleSpace而不是title。

    return Scaffold(
      appBar: AppBar(
        flexibleSpace: Container(....
    
        2
  •  0
  •   Adnan karim    6 年前

    flexibleSpace 很好,但另一种方法是 PrefferedSize

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