基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

40 line
1.0 KiB

  1. import 'package:flutter/material.dart';
  2. class HomeGoodsDelegate extends SliverPersistentHeaderDelegate {
  3. final TabController controller;
  4. HomeGoodsDelegate(this.controller);
  5. @override
  6. Widget build(
  7. BuildContext context, double shrinkOffset, bool overlapsContent) {
  8. // print(shrinkOffset.toString());
  9. return Container(
  10. color: Colors.red,
  11. alignment: Alignment.center,
  12. child: TabBar(
  13. controller: controller,
  14. isScrollable: true,
  15. tabs: <Widget>[
  16. Tab(icon: Icon(Icons.local_florist)),
  17. Tab(icon: Icon(Icons.change_history)),
  18. Tab(icon: Icon(Icons.directions_bike)),
  19. Tab(icon: Icon(Icons.local_florist)),
  20. Tab(icon: Icon(Icons.change_history)),
  21. Tab(icon: Icon(Icons.directions_bike)),
  22. ],
  23. ),
  24. );
  25. }
  26. @override
  27. double get maxExtent => 60.0;
  28. @override
  29. double get minExtent => 60.0;
  30. @override
  31. bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) =>
  32. false; // 如果内容需要更新,设置为true
  33. }