我想创建一个类似于 Apple News 应用程序中的顶部应用程序栏。
在屏幕截图中看到模糊有点困难,因为条形图太细了,但你明白了。
我希望该栏通过滚动来展开和收缩,并在收缩时固定在顶部,就像屏幕截图中一样,SliverAppBar 可以完成所有这些操作,只是我无法将其包裹在 ClipRect、BackdropFilter 和 Opacity 中以创建磨砂玻璃效果是因为 CustomScrollView 仅采用 RenderSliver 子类。
我的测试代码:
Widget build(BuildContext context) {
return CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('SliverAppBar'),
elevation: 0,
floating: true,
pinned: true,
backgroundColor: Colors.grey[50],
expandedHeight: 200.0,
flexibleSpace: FlexibleSpaceBar(
background: Image.network("https://i.imgur.com/cFzxleh.jpg", fit: BoxFit.cover)
),
)
,
SliverFixedExtentList(
itemExtent: 150.0,
delegate: SliverChildListDelegate(
[
Container(color: Colors.red),
Container(color: Colors.purple),
Container(color: Colors.green),
Container(color: Colors.orange),
Container(color: Colors.yellow),
Container(color: Colors.pink,
child: Image.network("https://i.imgur.com/cFzxleh.jpg", fit: BoxFit.cover)
),
],
),
),
],
);
}
Run Code Online (Sandbox Code Playgroud)
有办法实现我想要的吗?