Skip to content

Commit

Permalink
Apply review suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksokolovskyi committed May 30, 2024
1 parent 53a8543 commit e888493
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ void main() => runApp(const TweenAnimationBuilderExampleApp());
class TweenAnimationBuilderExampleApp extends StatelessWidget {
const TweenAnimationBuilderExampleApp({super.key});

static const Duration duration = Duration(seconds: 1);

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -29,12 +27,7 @@ class TweenAnimationBuilderExampleApp extends StatelessWidget {
}

class TweenAnimationBuilderExample extends StatefulWidget {
const TweenAnimationBuilderExample({
this.duration = TweenAnimationBuilderExampleApp.duration,
super.key,
});

final Duration duration;
const TweenAnimationBuilderExample({super.key});

@override
State<TweenAnimationBuilderExample> createState() =>
Expand All @@ -49,7 +42,7 @@ class _TweenAnimationBuilderExampleState
Widget build(BuildContext context) {
return TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0, end: _targetValue),
duration: widget.duration,
duration: const Duration(seconds: 1),
builder: (BuildContext context, double size, Widget? child) {
return IconButton(
iconSize: size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ void main() {
const example.TweenAnimationBuilderExampleApp(),
);

// The animation duration defined in the example app.
const Duration animationDuration = Duration(seconds: 1);

const double beginSize = 0.0;
const double endSize = 24.0;

Expand All @@ -24,9 +27,7 @@ void main() {
expect(iconButton.iconSize, equals(beginSize));

// Advance animation to the middle.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(
Expand All @@ -35,9 +36,7 @@ void main() {
);

// Advance animation to the end.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(iconButton.iconSize, equals(endSize));
Expand All @@ -49,6 +48,9 @@ void main() {
);
await tester.pumpAndSettle();

// The animation duration defined in the example app.
const Duration animationDuration = Duration(seconds: 1);

const double beginSize = 24.0;
const double endSize = 48.0;

Expand All @@ -65,9 +67,7 @@ void main() {
expect(iconButton.iconSize, equals(beginSize));

// Advance animation to the middle.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(
Expand All @@ -76,9 +76,7 @@ void main() {
);

// Advance animation to the end.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(iconButton.iconSize, equals(endSize));
Expand All @@ -91,9 +89,7 @@ void main() {
expect(iconButton.iconSize, equals(endSize));

// Advance animation to the middle.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(
Expand All @@ -102,9 +98,7 @@ void main() {
);

// Advance animation to the end.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(iconButton.iconSize, equals(beginSize));
Expand All @@ -116,6 +110,9 @@ void main() {
);
await tester.pumpAndSettle();

// The animation duration defined in the example app.
const Duration animationDuration = Duration(seconds: 1);

const double beginSize = 24.0;
const double endSize = 48.0;
final double middleSize = lerpDouble(beginSize, endSize, 0.5)!;
Expand All @@ -133,9 +130,7 @@ void main() {
expect(iconButton.iconSize, equals(beginSize));

// Advance animation to the middle.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(iconButton.iconSize, equals(middleSize));
Expand All @@ -148,9 +143,7 @@ void main() {
expect(iconButton.iconSize, equals(middleSize));

// Advance animation to the middle.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(
Expand All @@ -159,9 +152,7 @@ void main() {
);

// Advance animation to the end.
await tester.pump(
example.TweenAnimationBuilderExampleApp.duration ~/ 2,
);
await tester.pump(animationDuration ~/ 2);

iconButton = tester.widget(iconButtonFinder);
expect(iconButton.iconSize, equals(beginSize));
Expand Down

0 comments on commit e888493

Please sign in to comment.