Flutter:增加appBar图标的高度

问题描述 投票:0回答:1

我想放置一个图标代替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小部件中强制设置图标的高度?

flutter dart flutter-layout
1个回答
1
投票

应该看起来像这样

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,
  ),
),
© www.soinside.com 2019 - 2024. All rights reserved.