Skip to content

Commit

Permalink
BUG: Fix debug assertion on ShakeCurve animation.
Browse files Browse the repository at this point in the history
Flutter's Curve class requires that the `transform` function map 0 to ~0 and 1
to ~1. The previous ShakeCurve transform function sin(t * 3 * pi).abs(), which
doesn't satisfy this property because sin(3 * pi) is 0, not 1.

Changing the constant from 3 to 2.5 produces the required endpoint value for t
= 1.
  • Loading branch information
ssanderson committed Sep 3, 2020
1 parent 74d2235 commit e5f9a99
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/shake_curve.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class ShakeCurve extends Curve {
@override
double transform(double t) {
//t from 0.0 to 1.0
return sin(t * 3 * pi).abs();
return sin(t * 2.5 * pi).abs();
}
}

0 comments on commit e5f9a99

Please sign in to comment.