![](/img/trans.png)
[英]How to achieve nested slivers? A sliver containing a list of slivers
[英]How to achieve nested slivers in Flutter
我想在 Flutter 中實現以下功能:
CustomScrollView(
slivers: [
NestedSlivers(
slivers: [
SliverOutside(
child: SliverInside()
)
])
]
)
目前我正在使用帶有 ShrinkWrappingViewport 的 Slivers,但它的性能非常糟糕。 所以任何幫助或線索都會非常有用。 非常感謝!
您可以使用NestedScrollView
來實現相同的目的。
這是相同的示例:-
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: SliverAppBar(),
body: new NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
new SliverAppBar(
pinned: true,
title: new Text('App Bar'),
),
];
},
body: new Column(
children: <Widget>[
new FlutterLogo(size: 100.0, colors: Colors.purple),
new Container(
height: 300.0,
child: new ListView.builder(
itemCount: 60,
itemBuilder: (BuildContext context, int index) {
return new Text('Item No. $index');
},
),
),
new FlutterLogo(size: 50.0, colors: Colors.red),
],
),
),
);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.