|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import 'dart:ui';
-
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
-
- class MineHeaderDelegate extends SliverPersistentHeaderDelegate {
- double _height;
-
- MineHeaderDelegate() : super() {
- _height = MediaQueryData.fromWindow(window).padding.top + 44;
- }
-
- @override
- Widget build(
- BuildContext context, double shrinkOffset, bool overlapsContent) {
- print('${shrinkOffset.toString()}');
- double percent = shrinkOffset / _height;
- print('${percent.toString()}');
- return MineHeader(Colors.red.withOpacity(percent));
- }
-
- @override
- double get maxExtent => _height;
-
- @override
- double get minExtent => _height;
-
- @override
- bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) =>
- false; // 如果内容需要更新,设置为true
- }
-
- class MineHeader extends StatelessWidget {
- final Color color;
-
- MineHeader(this.color);
-
- @override
- Widget build(BuildContext context) {
- return Container(
- color: color,
- child: Column(
- children: <Widget>[
- Expanded(child: Container()),
- Container(
- width: double.infinity,
- height: 44,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Icon(
- Icons.settings,
- color: Colors.white,
- ),
- Icon(
- Icons.chat,
- color: Colors.white,
- )
- ],
- ),
- )
- ],
- ));
- }
- }
|