customSilverHeaderTabs.dart 696 B

1234567891011121314151617181920212223242526
  1. import 'package:flutter/cupertino.dart';
  2. class CustomSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
  3. final Widget child;
  4. double maxHeight = 100.0;
  5. double minHeight = 100.0;
  6. CustomSliverPersistentHeaderDelegate({required this.child, required this.maxHeight, required this.minHeight});
  7. @override
  8. double get maxExtent => maxHeight; // 最大高度
  9. @override
  10. double get minExtent => minHeight; // 最小高度
  11. @override
  12. Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
  13. return child;
  14. }
  15. @override
  16. bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
  17. return true;
  18. }
  19. }