Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add Page transition Animation with Flutter

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to add page transition animation by Flutter". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Use plug-ins to explore different transformations step 1: add page animation transformations in pubspec.yaml

Page_animation_transition

Step 2: import the library on PageOne

Suppose you are transitioning from PageOne to PageTwo

The following are the types of animation supported by the library:

BottomToTopTransition TopToBottomTransition bottom-to-up conversion

RightToLeftTransition right transfer

LeftToRightTransition left / right transition

FadeAnimationTransition watered down animation / conversion

ScaleAnimationTransition scalar animation / conversion

RotationAnimationTransition rotation / Animation / Transformation

TopToBottomFadedTransition top-to-bottom transition

BottomToTopFadedTransition bottom / upper / lower / upper /

RightToLeftFadedTransition turn right to / ftfaded/transition

LeftToRightFadedTransition left / right / insert / convert

Step 3. Add the following navigation code line Navigator.of (context) .push (page: const PageTwo (), pageAnimationType: BottomToTopTransition ())

For predefined routes:

OnGenerateRoute: (settings) {switch (settings.name) {case'/ pageTwo': return PageAnimationTransition (child: PageTwo (), pageAnimationType: LeftToRightFadedTransition ()); break; default: return null;}}

Navigator.pushNamed (context,'/ pageTwo')

Pushnamed (context,'/pageTwo')

Output:

Output:

Complete code for other type conversions: import 'package:page_animation_transition/animations/bottom_to_top_faded_transition.dart';import' package:page_animation_transition/animations/bottom_to_top_transition.dart';import 'package:page_animation_transition/animations/fade_animation_transition.dart';import' package:page_animation_transition/animations/left_to_right_faded_transition.dart';import 'package:page_animation_transition/animations/left_to_right_transition.dart' Import 'package:page_animation_transition/animations/right_to_left_faded_transition.dart';import' package:page_animation_transition/animations/right_to_left_transition.dart';import 'package:page_animation_transition/animations/rotate_animation_transition.dart';import' package:page_animation_transition/animations/scale_animation_transition.dart';import 'package:page_animation_transition/animations/top_to_bottom_faded.dart' Import 'package:page_animation_transition/animations/top_to_bottom_transition.dart';import' package:page_animation_transition/page_animation_transition.dart';import 'page_two.dart';import' package:flutter/material.dart';class PageOne extends StatelessWidget {const PageOne ({Key? Key}): super (key: key) Children: [ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: BottomToTopTransition () }, child: const Text ('Bottom To Top'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: TopToBottomTransition () }, child: const Text ('Top to bottom'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: RightToLeftTransition () }, child: const Text ('Right To Left'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: LeftToRightTransition () }, child: const Text ('Left to Right'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: FadeAnimationTransition () }, child: const Text ('Faded'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: ScaleAnimationTransition () }, child: const Text ('Scale'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: RotationAnimationTransition () }, child: const Text ('Rotate'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: TopToBottomFadedTransition () }, child: const Text ('Top to Bottom Faded'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: BottomToTopFadedTransition () }, child: const Text ('Bottom to Top Faded'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: RightToLeftFadedTransition () }, child: const Text ('Right to Left Faded'), ElevatedButton (onPressed: () {Navigator.of (context) .push (PageAnimationTransition (page: const PageTwo (), pageAnimationType: LeftToRightFadedTransition () }, child: const Text ('Left to Right Faded')),],);}}

Output:

This is the end of the content of "how to add page transition animation in Flutter". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report