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.
34 lines
796 B
34 lines
796 B
4 years ago
|
import 'dart:math';
|
||
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||
|
SliverAppBarDelegate({
|
||
|
@required this.minHeight,
|
||
|
@required this.maxHeight,
|
||
|
@required this.child,
|
||
|
});
|
||
|
|
||
|
final double minHeight;
|
||
|
final double maxHeight;
|
||
|
final Widget child;
|
||
|
|
||
|
@override
|
||
|
double get minExtent => minHeight;
|
||
|
|
||
|
@override
|
||
|
double get maxExtent => max(maxHeight, minHeight);
|
||
|
|
||
|
@override
|
||
|
Widget build(
|
||
|
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||
|
return new SizedBox.expand(child: child);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
bool shouldRebuild(SliverAppBarDelegate oldDelegate) {
|
||
|
return maxHeight != oldDelegate.maxHeight ||
|
||
|
minHeight != oldDelegate.minHeight ||
|
||
|
child != oldDelegate.child;
|
||
|
}
|
||
|
}
|