3

I have several register forms with next buttons and I would like to switch between the different screens with

onTap: () => { Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => SomeOtherScaffold()))
  },

but without the default animation that comes with it.

ungarmichael
  • 101
  • 1
  • 9

1 Answers1

1

If you want to use other animation, you can use transitionBuilder, in your PageRoute. How you can use this represented for you below:

import 'package:flutter/material.dart';

main() {
  runApp(MaterialApp(
    home: Page1(),
  ));
}

class Page1 extends StatelessWidget {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: RaisedButton(
          child: Text('Go!'),
          onPressed: () {
            Navigator.of(context).push(_createRoute());
          },
        ),
      ),
    );
  }
}

Route _createRoute() {
  return PageRouteBuilder(
    pageBuilder: (context, animation, secondaryAnimation) => Page2(),
    transitionsBuilder: (context, animation, secondaryAnimation, child) {
      return child;
    },
  );
}

And if you want to transition instantly, you can do this:

transitionDuration: Duration(seconds: 0)

This will decrease down the transition time to 0 second, which will eventually results to quick transition speed.

To know more about Page Animation Transition follow these articles:

  1. Page Route Animation
  2. Everything you need for Flutter Page Transition

You need to define something for your transition, if you don't want the default one, and this answer will help you achieve this.

halfer
  • 19,824
  • 17
  • 99
  • 186
Alok
  • 8,452
  • 13
  • 55
  • 93