Skip to content

Commit 9cf4b32

Browse files
committed
Refactor reverseCurve handling in Hero animations
- Updated the logic for the `reverseCurve` property in the Hero widget to simplify the assignment, ensuring that the flipped curve is applied only when necessary. - Adjusted related test cases to reflect the new handling of `reverseCurve`, maintaining consistency in animation behavior.
1 parent 6a568d5 commit 9cf4b32

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎packages/flutter/lib/src/widgets/heroes.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,11 @@ class _HeroFlightManifest {
477477
case HeroFlightDirection.push:
478478
parent = toRoute.animation!;
479479
curve = toHero.widget.curve;
480-
reverseCurve = (toHero.widget.reverseCurve ?? curve).flipped;
480+
reverseCurve = toHero.widget.reverseCurve ?? curve.flipped;
481481
case HeroFlightDirection.pop:
482482
parent = fromRoute.animation!;
483483
curve = fromHero.widget.curve;
484-
reverseCurve = (fromHero.widget.reverseCurve ?? curve).flipped;
484+
reverseCurve = fromHero.widget.reverseCurve ?? curve.flipped;
485485
}
486486

487487
return _animation ??= CurvedAnimation(

‎packages/flutter/test/widgets/heroes_test.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,7 +3312,7 @@ Future<void> main() async {
33123312
return RectTween(begin: begin, end: end);
33133313
},
33143314
curve: curve,
3315-
reverseCurve: reverseCurve,
3315+
reverseCurve: reverseCurve?.flipped,
33163316
child: SizedBox(key: container1, height: 100, width: 100),
33173317
),
33183318
),
@@ -3333,7 +3333,7 @@ Future<void> main() async {
33333333
return RectTween(begin: begin, end: end);
33343334
},
33353335
curve: curve,
3336-
reverseCurve: reverseCurve,
3336+
reverseCurve: reverseCurve?.flipped,
33373337
child: SizedBox(key: container2, height: 200, width: 200),
33383338
),
33393339
),

0 commit comments

Comments
 (0)