Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to navigate to a new page with a default animation.
Flutter
Navigator.of(context).push(MaterialPageRoute(builder: (context) => [1]())); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a widget that is not a page or screen.
Forgetting to call the widget constructor with parentheses.
✗ Incorrect
You need to specify the widget class of the new page to navigate to. Here, SecondPage is the correct page widget.
2fill in blank
mediumComplete the code to create a fade transition animation when navigating.
Flutter
Navigator.of(context).push(PageRouteBuilder(pageBuilder: (context, animation, secondaryAnimation) => SecondPage(), transitionsBuilder: (context, animation, secondaryAnimation, child) => FadeTransition(opacity: [1], child: child),)); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using secondaryAnimation instead of animation.
Using a fixed opacity value instead of an animation.
✗ Incorrect
The FadeTransition uses the animation object directly as the opacity to animate the fade effect.
3fill in blank
hardFix the error in the slide transition code to slide the new page from the right.
Flutter
Navigator.of(context).push(PageRouteBuilder(pageBuilder: (context, animation, secondaryAnimation) => SecondPage(), transitionsBuilder: (context, animation, secondaryAnimation, child) => SlideTransition(position: animation.drive(Tween<Offset>(begin: [1], end: Offset.zero).chain(CurveTween(curve: Curves.easeInOut))), child: child),)); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using negative x offset which slides from left instead of right.
Using y offsets which slide vertically instead of horizontally.
✗ Incorrect
To slide the page in from the right, the begin offset should be (1.0, 0.0), meaning start fully right off-screen.
4fill in blank
hardFill both blanks to create a scale transition that grows the new page from nothing to full size.
Flutter
Navigator.of(context).push(PageRouteBuilder(pageBuilder: (context, animation, secondaryAnimation) => SecondPage(), transitionsBuilder: (context, animation, secondaryAnimation, child) => ScaleTransition(scale: animation.drive(Tween<double>(begin: [1], end: [2]).chain(CurveTween(curve: Curves.easeIn))), child: child),));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using begin scale larger than end scale causing reverse animation.
Using values greater than 1.0 which enlarges the page beyond normal size.
✗ Incorrect
The scale should start at 0.0 (no size) and grow to 1.0 (full size) for a smooth scale-up animation.
5fill in blank
hardFill all three blanks to create a rotation transition that spins the new page in while fading it in.
Flutter
Navigator.of(context).push(PageRouteBuilder(pageBuilder: (context, animation, secondaryAnimation) => SecondPage(), transitionsBuilder: (context, animation, secondaryAnimation, child) => FadeTransition(opacity: animation, child: RotationTransition(turns: animation.drive(Tween<double>(begin: [1], end: [2]).chain(CurveTween(curve: Curves.easeInOut))), child: child),),));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive begin value which spins clockwise instead of counterclockwise.
Not chaining the curve tween for smooth animation.
✗ Incorrect
The rotation starts at -1.0 turns (one full spin counterclockwise) and ends at 0.0 (no rotation), while opacity animates from 0 to 1 for fade-in.