return Scaffold(
appBar:
PreferredSize(
preferredSize: Size.fromHeight(120),// change appbar size
child:AppBar(
backgroundColor: Color.fromARGB(255,254,202,8),
leading:RawMaterialButton(
constraints: BoxConstraints(),
padding: EdgeInsets.all(0),
child: Image.asset("assets/img/home.png",height:110), // set height as 110
),
title:Text("mytitle");
我通过preferredSize
更改了应用栏的高度并将领先的图像高度设置为
100
AppBar的高度已更改,但前导图标的大小未更改。还有文字。
如何根据应用栏大小更改行距和文本大小?
最佳答案
无法更改leading
中AppBar
的大小,但是一种解决方法是使用包含图像和标题的Row
并将此行设置为flexibleSpace
的AppBar
:
AppBar(
backgroundColor: Color.fromARGB(255, 254, 202, 8),
flexibleSpace: Row(
children: <Widget>[
RawMaterialButton(
constraints: BoxConstraints(),
padding: EdgeInsets.all(0),
child: Image.asset(
"assets/img/home.png",
height: 110,
),
),
Text("mytitle"),
],
),
),
关于flutter - 根据Appbar的高度更改标题和标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63398323/