import 'package:flutter/material.dart';
import 'package:sizer/sizer.dart';

class SliverHeaderDelegate extends SliverPersistentHeaderDelegate {
  final Widget child;
  final String? value;

  SliverHeaderDelegate({required this.child, this.value});

  @override
  double get minExtent => 7.h;

  @override
  double get maxExtent => 7.h;

  @override
  Widget build(
    BuildContext context,
    double shrinkOffset,
    bool overlapsContent,
  ) {
    return Material(
      color: Colors.white,
      child: Container(alignment: Alignment.centerLeft, child: child),
    );
  }

  @override
  bool shouldRebuild(covariant SliverHeaderDelegate oldDelegate) {
     return value != null ? (oldDelegate.value != value || oldDelegate.child != child) : false;
  }
}
