颤振:增加appBar图标的高度

时间:2019-10-08 08:16:53

标签: flutter dart flutter-layout

我想放置一个图标而不是appBar小部件的标题,但是我不能为此图标设置适当的高度。

enter image description here

appBar: PreferredSize(
  preferredSize: Size.fromHeight(220.0),
  child: AppBar(
    title: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Image.asset(
          'assets/mobile-phone.png',
          fit: BoxFit.contain,
          width: 120,
          height: 120,
        )
      ],
    ),
    elevation: 0.0,
    backgroundColor: Colors.green,
    brightness: Brightness.light,
  ),
),

尽管我将高度设置得更大并且它的实际大小也变大了,但图标仍达到其最大大小约60(单位?)。

如何在appBar小部件中强制设置图标的高度?

1 个答案:

答案 0 :(得分:3)

这应该看起来像这样

appBar: PreferredSize(
  preferredSize: Size.fromHeight(220.0),
  child: AppBar(
    flexibleSpace: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Image.asset(
          'assets/mobile-phone.png',
          fit: BoxFit.contain,
          width: 120,
          height: 120,
        )
      ],
    ),
    elevation: 0.0,
    backgroundColor: Colors.green,
    brightness: Brightness.light,
  ),
),