我有一个带有sliver的CustomScrollView,它可以工作,但我找不到完全隐藏SliverAppBar顶部部分的方法(即,在滚动时,我想隐藏图像和标题,但显示底部部分):
编辑:如图所示,我想在滚动时保留SliverAppBar的底部。设置“pinned:false”会在滚动时隐藏两者,因此对我没有用。 即使在添加内边距之前,我也希望我的标题在折叠时隐藏,像这样:
编辑:如图所示,我想在滚动时保留SliverAppBar的底部。设置“pinned:false”会在滚动时隐藏两者,因此对我没有用。 即使在添加内边距之前,我也希望我的标题在折叠时隐藏,像这样:
现在它被截断了,我真的很想隐藏它。
我看过一些帖子,在NestedScrollView中可以隐藏标题(例如上面的gif),但如果可能的话,我想保留我的CustomScrollView?
这是我的代码:
class QuestionsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final questionsMgr = Provider.of<Questions>(context);
final List<Question> questions = questionsMgr.questions;
return CustomScrollView(
slivers: <Widget>[
SliverAppBar(
bottom: PreferredSize(
preferredSize: const Size.fromHeight(0),
child: ChangeNotifierProvider.value(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
ScoreText(),
InstructionsText(),
],
),
),
),
),
backgroundColor: questionsMgr.getScoreColor(),
floating: false,
expandedHeight: 225,
pinned: true,
title: Text(
"Checklist",
textAlign: TextAlign.center,
),
forceElevated: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
background: Image.asset(
"assets/images/PalFM_blue.jpg",
fit: BoxFit.cover,
),
),
),
SliverList(