我想在此处将图像作为AppBar
的背景:
我知道的唯一方法是使用flexibleSpace
的SliverAppBar
(在CustomScrollView
内部),因为普通的AppBar
不会更改其大小以容纳图像。
问题是SliverAppBar
需要经过硬编码的expandedHeight
,并且我的每个屏幕都将显示具有不同高度的不同图像,因此我需要以编程方式获取高度并将其传递给expandedHeight
。] >
是否有可能获得图像的未来高度,以使图像不会扭曲并填满屏幕的宽度,所以我可以将其传递给expandedHeight
?
我想在此处放置图像作为我的AppBar的背景:我知道的唯一方法是使用SliverAppBar的flexibleSpace(在CustomScrollView内),因为普通的AppBar不会更改它......] >
使用应用栏的flexibleSpace
属性并使用your Image
AppBar(
title: Text('My App'),
flexibleSpace: Image(
image: AssetImage('assets/image.png'), // or Image.asset and give your size to image using height and width property of Image.asset widget
fit: BoxFit.cover,
),