persistent_header.dart 567 B

12345678910111213141516171819202122232425
  1. import 'package:flutter/material.dart';
  2. class PersistentHeader extends SliverPersistentHeaderDelegate {
  3. final double max;
  4. final double min;
  5. final Widget child;
  6. PersistentHeader({this.max = 50.0, this.min = 50.0, required this.child});
  7. @override
  8. Widget build(
  9. BuildContext context, double shrinkOffset, bool overlapsContent) {
  10. return child;
  11. }
  12. @override
  13. double get maxExtent => max;
  14. @override
  15. double get minExtent => min;
  16. @override
  17. bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) =>
  18. oldDelegate != this;
  19. }