neeraja
neeraja

Reputation: 21

flutter page Transition add in main.dart routes

how can add page transition right to left by this package " page_transition: ^2.1.0"

here code

 routes: {
              '/notification_screen': (context) =>  Notification_screen(),
              '/': (context) =>
              (token != null && JwtDecoder.isExpired(token) == false)
                  ? darkmode ? NightSDashboard(token: token) : SDashboard(token: token)
                  : SpalshScreen(),
             
              '/quizpage': (context) {
              
                final Map<String, dynamic> arguments = ModalRoute.of(context)!
                    .settings
                    .arguments as Map<String, dynamic>;
 

                final String userId = arguments['UserId']; // Update to 'userId'
                final String email = arguments['email']; // Update to 'userId'
                final String mobile = arguments['mobile']; // Update to 'userId'
                final String name = arguments['name']; // Update to 'userId'

 
                return  DailyQuizScreen(
                    UserId: userId, // Update to 'userId'
                    email: email, // Update to 'userId'
                    mobile: mobile, // Update to 'userId'
                    name: name, // Update to 'userId'

                );
              },
}

here below expected code that added page transition PageTransitionType.rightToLeft


             
              '/quizpage': (context) {
             
                final Map<String, dynamic> arguments = ModalRoute.of(context)!
                    .settings
                    .arguments as Map<String, dynamic>;

                final String userId = arguments['UserId']; // Update to 'userId'
                final String email = arguments['email']; // Update to 'userId'
                final String mobile = arguments['mobile']; // Update to 'userId'
                final String name = arguments['name']; // Update to 'userId'
 
                return  PageTransition(
                  type: PageTransitionType.rightToLeft,
                  child: DailyQuizScreen(
                      UserId: userId, // Update to 'userId'
                      email: email, // Update to 'userId'
                      mobile: mobile, // Update to 'userId'
                      name: name, // Update to 'userId'

                  ),
                );
              },
 

here getting The return type 'PageTransition' isn't a 'Widget', as required by the closure's context. how to fix this thanks

Upvotes: 1

Views: 37

Answers (0)

Related Questions