import 'package:flutter/material.dart'; class HomeGoodsDelegate extends SliverPersistentHeaderDelegate { @override Widget build( BuildContext context, double shrinkOffset, bool overlapsContent) { // print(shrinkOffset.toString()); return Container( color: Colors.red, alignment: Alignment.center, child: TabBar( controller: TabController(initialIndex: 0, length: 6, vsync: ScrollableState()), isScrollable: true, tabs: [ Tab(icon: Icon(Icons.local_florist)), Tab(icon: Icon(Icons.change_history)), Tab(icon: Icon(Icons.directions_bike)), Tab(icon: Icon(Icons.local_florist)), Tab(icon: Icon(Icons.change_history)), Tab(icon: Icon(Icons.directions_bike)), ], ), ); } @override double get maxExtent => 64.0; @override double get minExtent => 64.0; @override bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => false; // 如果内容需要更新,设置为true }