直接上代码
CustomScrollView(
slivers: <Widget>[
SliverAppBar(
pinned: true,
expandedHeight: 200.0,
centerTitle: true,
automaticallyImplyLeading: true,
primary: true,
leading: Icon(Icons.invert_colors_on_sharp),
actions: [
Icon(Icons.ac_unit_rounded),
Container(
child: Icon(Icons.access_alarm_outlined),
margin: EdgeInsets.symmetric(horizontal: 10.w),
)
],
iconTheme: colorTheme.iconTheme,
titleSpacing: 50,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
collapseMode: CollapseMode.pin,
title: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width / 1.5,
),
child: Container(
margin: EdgeInsets.only(right: 20, left: 20 / 1.5),
// padding: EdgeInsets.only(right: 10, left: 10),
height: 25,
// alignment: Alignment.centerLeft,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.r),
color: Colors.white,
),
),
),
),
),
SliverGrid.count(crossAxisCount: 4,children: List.generate(8, (index){
return Container(
color: Colors.primaries[index%Colors.primaries.length],
alignment: Alignment.center,
child: Text('$index',style: TextStyle(color: Colors.white,fontSize: 20),),
);
}).toList(),),
SliverList(
delegate: SliverChildBuilderDelegate((content, index) {
return Container(
height: 85,
alignment: Alignment.center,
color: Colors.primaries[index % Colors.primaries.length],
child: Text('$index',style: TextStyle(color: Colors.white,fontSize: 20),),
);
}, childCount: 25),
)
// Header(),
// Body(),
],
),
)```