Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/src/image/fade_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class _FadeWidgetState extends State<FadeWidget>
late Animation<double> opacity;
late AnimationController controller;
late bool hideWidget;
CurvedAnimation? curved;

@override
Widget build(BuildContext context) {
Expand All @@ -59,6 +60,7 @@ class _FadeWidgetState extends State<FadeWidget>
super.initState();
controller = AnimationController(duration: widget.duration, vsync: this);
final curved = CurvedAnimation(parent: controller, curve: widget.curve);
this.curved = curved;
var begin = widget.direction == AnimationDirection.forward ? 0.0 : 1.0;
var end = widget.direction == AnimationDirection.forward ? 1.0 : 0.0;
opacity = Tween<double>(begin: begin, end: end).animate(curved);
Expand All @@ -81,7 +83,10 @@ class _FadeWidgetState extends State<FadeWidget>
opacity.removeStatusListener(animationStatusChange);
controller.duration = widget.duration;
controller.value = 0;
this.curved?.dispose();
this.curved = null;
final curved = CurvedAnimation(parent: controller, curve: widget.curve);
this.curved = curved;
var begin = widget.direction == AnimationDirection.forward ? 0.0 : 1.0;
var end = widget.direction == AnimationDirection.forward ? 1.0 : 0.0;
opacity = Tween<double>(begin: begin, end: end).animate(curved);
Expand All @@ -101,6 +106,8 @@ class _FadeWidgetState extends State<FadeWidget>
void dispose() {
opacity.removeStatusListener(animationStatusChange);
controller.dispose();
curved?.dispose();
curved = null;
super.dispose();
}

Expand Down