Fix: Update DelegatedTransition animation parameter correctly (#163853)

Fix: Update DelegatedTransition animation parameter correctly
fixes: #163389 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
This commit is contained in:
Kishan Rathore
2025-03-01 02:35:26 +05:30
committed by GitHub
parent 34a11c405d
commit 1bafd3e0d6
2 changed files with 93 additions and 1 deletions

View File

@@ -763,7 +763,7 @@ class FadeForwardsPageTransitionsBuilder extends PageTransitionsBuilder {
Animation<double> secondaryAnimation,
bool allowSnapshotting,
Widget? child,
) => _delegatedTransition(context, animation, backgroundColor, child);
) => _delegatedTransition(context, secondaryAnimation, backgroundColor, child);
// Used by all of the sliding transition animations.
static const Curve _transitionCurve = Curves.easeInOutCubicEmphasized;

View File

@@ -229,6 +229,98 @@ void main() {
variant: TargetPlatformVariant.only(TargetPlatform.android),
);
group('FadeForwardsPageTransitionsBuilder transitions', () {
testWidgets(
'opacity fades out during forward secondary animation',
(WidgetTester tester) async {
final AnimationController controller = AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
addTearDown(controller.dispose);
final Animation<double> animation = Tween<double>(begin: 1, end: 0).animate(controller);
final Animation<double> secondaryAnimation = Tween<double>(
begin: 0,
end: 1,
).animate(controller);
await tester.pumpWidget(
Builder(
builder: (BuildContext context) {
return const FadeForwardsPageTransitionsBuilder().delegatedTransition!(
context,
animation,
secondaryAnimation,
false,
const SizedBox(),
)!;
},
),
);
final RenderAnimatedOpacity? renderOpacity =
tester
.element(find.byType(SizedBox))
.findAncestorRenderObjectOfType<RenderAnimatedOpacity>();
// Since secondary animation is forward, transition will be reverse between duration 0 to 0.25.
controller.value = 0.0;
await tester.pump();
expect(renderOpacity?.opacity.value, 1.0);
controller.value = 0.25;
await tester.pump();
expect(renderOpacity?.opacity.value, 0.0);
},
variant: TargetPlatformVariant.only(TargetPlatform.android),
);
testWidgets(
'opacity fades in during reverse secondary animaation',
(WidgetTester tester) async {
final AnimationController controller = AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
addTearDown(controller.dispose);
final Animation<double> animation = Tween<double>(begin: 0, end: 1).animate(controller);
final Animation<double> secondaryAnimation = Tween<double>(
begin: 1,
end: 0,
).animate(controller);
await tester.pumpWidget(
Builder(
builder: (BuildContext context) {
return const FadeForwardsPageTransitionsBuilder().delegatedTransition!(
context,
animation,
secondaryAnimation,
false,
const SizedBox(),
)!;
},
),
);
final RenderAnimatedOpacity? renderOpacity =
tester
.element(find.byType(SizedBox))
.findAncestorRenderObjectOfType<RenderAnimatedOpacity>();
// Since secondary animation is reverse, transition will be forward between duration 0.75 to 1.0.
controller.value = 0.75;
await tester.pump();
expect(renderOpacity?.opacity.value, 0.0);
controller.value = 1.0;
await tester.pump();
expect(renderOpacity?.opacity.value, 1.0);
},
variant: TargetPlatformVariant.only(TargetPlatform.android),
);
});
testWidgets(
'FadeForwardsPageTransitionBuilder default duration is 800ms',
(WidgetTester tester) async {