This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
LocalSpend-Tracker/lib/common/widgets/animatedGradientButton.dart

41 lines
1 KiB
Dart
Raw Normal View History

2019-08-20 12:54:45 +00:00
import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';
class AnimatedBackground extends StatelessWidget {
2019-08-20 15:01:56 +00:00
AnimatedBackground(
this.animateColors,
this.lastColor,
this.begin,
this.end,
this.duration,
2019-08-20 15:01:56 +00:00
);
final List<Color> animateColors;
final Color lastColor;
final Alignment begin, end;
final int duration;
2019-08-20 12:54:45 +00:00
@override
Widget build(BuildContext context) {
final tween = MultiTrackTween([
Track("color1").add(Duration(seconds: this.duration),
2019-08-20 15:01:56 +00:00
ColorTween(begin: this.animateColors[0], end: this.animateColors[1])),
2019-08-20 12:54:45 +00:00
]);
return ControlledAnimation(
playback: Playback.MIRROR,
tween: tween,
duration: tween.duration,
builder: (context, animation) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
2019-08-20 15:01:56 +00:00
begin: this.begin,
end: this.end,
colors: [animation["color1"], this.lastColor])),
2019-08-20 12:54:45 +00:00
);
},
);
}
}