I want to test my AnimatedPositioned
widget’s proper animation, so here is my code and it’s widget test:
Code:
AnimatedPositioned(
key: const Key('get_started_overlay'),
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
left: 0,
right: 0,
top: isOverlayVisible ? 0 : size.height,
child: Child()
),
Test:
testWidgets(
'proper functioning of AnimatedPositioned animation',
(widgetTester) async {
await widgetTester.pumpWidget(
const MediaQuery(
data: MediaQueryData(size: Size(2560, 1600)),
child: GetStartedScreen(),
),
);
expect(
widgetTester
.widget<AnimatedPositioned>(
find.byKey(const Key('get_started_overlay')))
.top,
1600,
);
await widgetTester.tap(find.byKey(Key('intro_video_widget')));
await widgetTester.pump(const Duration(milliseconds: 250));
expect(
widgetTester
.widget<AnimatedPositioned>(
find.byKey(const Key('get_started_overlay')))
.top,
800,
);
},
);
Here, after 250 ms
, I was actually expecting the animation to be more or less the half way there (top: 800)
… But, I got the error saying:
The following TestFailure was thrown running a test:
Expected: <800>
Actual: <0.0>
So, I want to be able to put breakpoint, so I could figured out what is wrong with the code and why it throws the aforementioned error, any help would be appreciated !