![]() |
VOOZH | about |
In Flutter, the page_transition package is used to create beautiful page transitions. It provides a wide range of effects that can be used from moving from one route to another. It is very convenient to use. In this article, we will explore the same by building a simple application.
You can add the page_transition dependency to the pubspec.yaml file as follows:
dependencies:
page_transition: ^2.2.1
Now run the below command in terminal.
flutter pub getTo import the dependency to your main.dart file use the following:
import 'package:page_transition/page_transition.dart';The StatelessWidget can be used to give a simple structure to the application that contains an appbar and a body for the content as shown below:
A StatelessWidget can also be used to design the Homepage for the app. A button will also be added to the homepage which will have a transition action attached to it when pressed as shown below:
To know more about Navigator refer this article: Flutter – Navigate From One Screen to Another
The onRouteSettings property is used to extract information from one page and send it to another page (or, route). We will assign the same property to the button action that we added in the homepage that will transition it to the second page as shown below:
Output: