import 'package:flutter/material.dart'; ///动态颜色混合 class AnimatedColorRevert extends ImplicitlyAnimatedWidget { final Widget child; final Color color; AnimatedColorRevert({ this.child, this.color, Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.easeInOutCubic, }) : super( duration: duration, curve: curve, ); @override ImplicitlyAnimatedWidgetState createState() => _AnimatedColorRevertState(); } class _AnimatedColorRevertState extends AnimatedWidgetBaseState { ColorTween _colorTween; @override Widget build(BuildContext context) { return ColorFiltered( colorFilter: ColorFilter.mode( _colorTween.evaluate(animation), BlendMode.modulate, ), child: widget.child, ); } @override void forEachTween(context) { _colorTween = context( _colorTween, widget.color, (dynamic value) => ColorTween(begin: value), ); } }