我是扑扑和飞镖编程的新手。但是最近我遇到了一些奇怪的行为,我无法弄清。每当我在代码中使用默认的SliverAppBar
时,就会出现flexibleSpace
,如以下代码所示。
SliverAppBar(
pinned: true,
expandedHeight: 200.0,
floating: true,
snap: true,
elevation: 0.1,
shape: Border(
bottom: BorderSide(width: 1.0, color: Colors.red),
),
title: Text('No title'),
flexibleSpace: FlexibleSpaceBar(
background: Image.asset('assets/images/placeholder.png'),
),
),
但是当我使用如下所示的自定义SliverAppBar
时,flexibleSpace
没有显示。
MySliverAppBar(
pinned: true,
expandedHeight: 200.0,
title: Text('No title'),
flexibleSpace: FlexibleSpaceBar(
background: Image.asset('assets/images/placeholder.png'),
),
),
....
class MySliverAppBar extends SliverAppBar {
MySliverAppBar({
Key key,
Widget leading,
Widget title,
bool pinned = false,
Widget flexibleSpace,
List<Widget> actions,
PreferredSizeWidget bottom,
double expandedHeight,
bool forceElevated = false,
}) : super(
key: key,
leading: leading,
title: title,
elevation: 0.1,
actions: actions,
floating: true,
snap: true,
pinned: pinned,
shape: Border(
bottom: BorderSide(width: 1.0, color: Colors.red),
),
bottom: bottom,
forceElevated: forceElevated,
expandedHeight: expandedHeight,
);
}
我不知道发生了什么。请帮忙。