stefanmuke stefanmuke - 3 years ago 200
Dart Question

Build transition for pageRouteBuilder in Flutter

I have implemented routing in my flutter app via on-the-fly route generation with

onPressed:() => Navigator.of(context).push(new PageRouteBuilder(
pageBuilder: (_, __, ___) => new Video(),

The transition from one page to another however is instant and without the native 'in from left' or 'in from bottom' animation, depending on whether you target iOS or Android. Is there a way to implement the native OS transitions without having to implement the animation from scratch.

I know that you can pass the
parameter to the
to create transitions, but so far I haven't found any information on how to create the necessary transitions or whether premade transitions are available. Any help with the implementation of the native transitions mentioned above would be appreciated!

Answer Source

You can just use MaterialPageBuilder instead of PageRouteBuilder.

To play video, you can look into this.


import 'package:chewie/chewie.dart';

final playerWidget = new Chewie(
  new VideoPlayerController(
  aspectRatio: 3 / 2,
  autoPlay: true,
  looping: true,

 onPressed:() => Navigator.of(context).push(new MaterialPageRoute(
   pageBuilder: (BuildContext context) {
      return new Container(child: playerWidget);

Hope this helped!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download