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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

44 lines
1.0 KiB

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<ImplicitlyAnimatedWidget> createState() =>
_AnimatedColorRevertState();
}
class _AnimatedColorRevertState
extends AnimatedWidgetBaseState<AnimatedColorRevert> {
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),
);
}
}