我想让我的 AppBar 持久化(它不应该像标签栏一样浮动),而我想在 appbar 下方放置一个小部件或说标签栏,它将浮动并固定到 appbar,就像库页面的 spotify 应用程序一样,请参阅下面的正确理解
到目前为止,我在颤振中使用的条子无法达到我想要的效果,请检查我的代码并纠正我,
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(body: Test()),
);
}
}
class Test extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: DefaultTabController(
length: 2,
child: NestedScrollView(
headerSliverBuilder: (context, value) {
return [
SliverAppBar(excludeHeaderSemantics: true,
floating: true,
pinned: true,
title: Text('This should be fixed not moving'),
bottom: TabBar(
tabs: [
Tab( text: "Call"), // this shoudl be floating n pinned
Tab( text: "Message"),// this should be floating n pinned
],
),
),
];
},
body: TabBarView(
children: [
Container(child: ListView.builder(
itemCount: 100,
itemBuilder: (context,index){
return Text("Item $index");
})),
Container(child: ListView.builder(
itemCount: 100,
itemBuilder: (context,index){
return Text("Item $index");
})),
],
),
),
),
);
}
}